<?php

declare(strict_types=1);

namespace Apexl\Io\User\Services;

use Apexl\Io\User\Interfaces\StampedActorResolverInterface;

/**
 * The default: the audit columns name a user, so the current user's id is the answer,
 * and there being no current user means there is no actor to name.
 */
final readonly class CurrentUserStampedActorResolver implements StampedActorResolverInterface
{
    public function __construct(
        private CurrentUserFactory $currentUserFactory,
    ) {}

    public function id(): ?int
    {
        $id = $this->currentUserFactory->get()?->id;

        return $id === null ? null : (int) $id;
    }
}
