<?php

namespace App\Factory;

use App\DataFixtures\FakeValues;
use App\Entity\Partner;
use App\Enum\PartnerType;
use App\Repository\PartnerRepository;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

/**
 * @extends ModelFactory<Partner>
 *
 * @method        Partner|Proxy                     create(array|callable $attributes = [])
 * @method static Partner|Proxy                     createOne(array $attributes = [])
 * @method static Partner|Proxy                     find(object|array|mixed $criteria)
 * @method static Partner|Proxy                     findOrCreate(array $attributes)
 * @method static Partner|Proxy                     first(string $sortedField = 'id')
 * @method static Partner|Proxy                     last(string $sortedField = 'id')
 * @method static Partner|Proxy                     random(array $attributes = [])
 * @method static Partner|Proxy                     randomOrCreate(array $attributes = [])
 * @method static PartnerRepository|RepositoryProxy repository()
 * @method static Partner[]|Proxy[]                 all()
 * @method static Partner[]|Proxy[]                 createMany(int $number, array|callable $attributes = [])
 * @method static Partner[]|Proxy[]                 createSequence(iterable|callable $sequence)
 * @method static Partner[]|Proxy[]                 findBy(array $attributes)
 * @method static Partner[]|Proxy[]                 randomRange(int $min, int $max, array $attributes = [])
 * @method static Partner[]|Proxy[]                 randomSet(int $number, array $attributes = [])
 */
final class PartnerFactory 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()->randomElement(FakeValues::COMPANY_NAMES)." ".self::faker()->randomElement(FakeValues::COMPANY_LEGAL_FORMS),
            'type' => self::faker()->randomElement(PartnerType::cases()),
            'description' => self::faker()->text(),
            'street' => self::faker()->randomElement(FakeValues::STREETS),
            'streetNo' => self::faker()->numberBetween(1,1000),
            'zip' => self::faker()->numberBetween(1000,10000),
            'city' => self::faker()->randomElement(FakeValues::CITIES),
            'country' => self::faker()->randomElement(FakeValues::COUNTRIES),
            'website' => 'https://spawntree.de/',
            'createdBy' => UserFactory::random()
        ];
    }

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

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