<?php

namespace App\Factory;

use App\Entity\Source;
use App\Repository\SourceRepository;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

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

    /**
     * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories
     *
     * @todo add your default values here
     */
    protected function getDefaults(): array
    {
        return [
            'name' => self::faker()->optional()->company(),
            'description' => self::faker()->optional()->text(),
            'baseUrl' => self::faker()->url(),
            'scrappingParameters' => [],
            'isActive' => self::faker()->boolean(),
            'createdAt' => \DateTimeImmutable::createFromMutable(self::faker()->dateTime()),
            'updatedAt' => \DateTimeImmutable::createFromMutable(self::faker()->dateTime()),
        ];
    }

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

    protected static function getClass(): string
    {
        return Source::class;
    }
}
