<?php

namespace App\Tests\Factory;

use App\Entity\ApiToken;
use App\Repository\ApiTokenRepository;
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;
use Zenstruck\Foundry\Persistence\RepositoryDecorator;

/**
 * @extends PersistentObjectFactory<ApiToken>
 *
 * @method        ApiToken                               create(array|callable $attributes = [])
 * @method static ApiToken                               createOne(array $attributes = [])
 * @method static ApiToken                               find(object|array|mixed $criteria)
 * @method static ApiToken                               findOrCreate(array $attributes)
 * @method static ApiToken                               first(string $sortedField = 'id')
 * @method static ApiToken                               last(string $sortedField = 'id')
 * @method static ApiToken                               random(array $attributes = [])
 * @method static ApiToken                               randomOrCreate(array $attributes = [])
 * @method static ApiTokenRepository&RepositoryDecorator repository()
 * @method static list<ApiToken>                         all()
 * @method static list<ApiToken>                         createMany(int $number, array|callable $attributes = [])
 * @method static list<ApiToken>                         createSequence(iterable|callable $sequence)
 * @method static list<ApiToken>                         findBy(array $attributes)
 * @method static list<ApiToken>                         randomRange(int $min, int $max, array $attributes = [])
 * @method static list<ApiToken>                         randomSet(int $number, array $attributes = [])
 */
final class ApiTokenFactory extends PersistentObjectFactory
{
    /**
     * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services
     *
     * @todo inject services if required
     */
    public function __construct()
    {
        parent::__construct();
    }

    public static function class(): string
    {
        return ApiToken::class;
    }

    /**
     * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
     *
     * @todo add your default values here
     */
    protected function defaults(): array
    {
        return [
            'ownedBy' => UserFactory::new(),
            'scopes' => [],
        ];
    }

    /**
     * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
     */
    protected function initialize(): static
    {
        return $this
            // ->afterInstantiate(function(ApiToken $apiToken): void {})
        ;
    }
}
