<?php

namespace App\Factory;

use App\Entity\UserProduct;
use App\Repository\UserProductRepository;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

/**
 * @extends ModelFactory<UserProduct>
 *
 * @method        UserProduct|Proxy                     create(array|callable $attributes = [])
 * @method static UserProduct|Proxy                     createOne(array $attributes = [])
 * @method static UserProduct|Proxy                     find(object|array|mixed $criteria)
 * @method static UserProduct|Proxy                     findOrCreate(array $attributes)
 * @method static UserProduct|Proxy                     first(string $sortedField = 'id')
 * @method static UserProduct|Proxy                     last(string $sortedField = 'id')
 * @method static UserProduct|Proxy                     random(array $attributes = [])
 * @method static UserProduct|Proxy                     randomOrCreate(array $attributes = [])
 * @method static UserProductRepository|RepositoryProxy repository()
 * @method static UserProduct[]|Proxy[]                 all()
 * @method static UserProduct[]|Proxy[]                 createMany(int $number, array|callable $attributes = [])
 * @method static UserProduct[]|Proxy[]                 createSequence(iterable|callable $sequence)
 * @method static UserProduct[]|Proxy[]                 findBy(array $attributes)
 * @method static UserProduct[]|Proxy[]                 randomRange(int $min, int $max, array $attributes = [])
 * @method static UserProduct[]|Proxy[]                 randomSet(int $number, array $attributes = [])
 */
final class UserProductFactory 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 [
            'createdAt' => \DateTimeImmutable::createFromMutable(self::faker()->dateTime()),
            'user' => UserFactory::new(),
            'product' => ProductFactory::new(),
        ];
    }

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

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