<?php
namespace Fifa\ConnectId\Sdk\Util;

use Fifa\ConnectId\Sdk\ActorResolver\ActorResolverInterface;

/**
 * Class ActorEncoder
 * @package Fifa\ConnectId\Sdk\Util
 */
class ActorEncoder
{
    /**
     * @param ActorResolverInterface $actorResolver
     * @return null|string
     */
    public static function encode(ActorResolverInterface $actorResolver): ?string
    {
        $actor = $actorResolver->resolve();
        if (is_null($actor) || strlen($actor) == 0) {
            return null;
        }

        return base64_encode($actor);
    }
}