<?php

namespace App\Factory;

use App\DataFixtures\FakeValues;
use App\Entity\Product;
use App\Repository\ProductRepository;
use Zenstruck\Foundry\ModelFactory;
use Zenstruck\Foundry\Proxy;
use Zenstruck\Foundry\RepositoryProxy;

/**
 * @extends ModelFactory<Product>
 *
 * @method        Product|Proxy                     create(array|callable $attributes = [])
 * @method static Product|Proxy                     createOne(array $attributes = [])
 * @method static Product|Proxy                     find(object|array|mixed $criteria)
 * @method static Product|Proxy                     findOrCreate(array $attributes)
 * @method static Product|Proxy                     first(string $sortedField = 'id')
 * @method static Product|Proxy                     last(string $sortedField = 'id')
 * @method static Product|Proxy                     random(array $attributes = [])
 * @method static Product|Proxy                     randomOrCreate(array $attributes = [])
 * @method static ProductRepository|RepositoryProxy repository()
 * @method static Product[]|Proxy[]                 all()
 * @method static Product[]|Proxy[]                 createMany(int $number, array|callable $attributes = [])
 * @method static Product[]|Proxy[]                 createSequence(iterable|callable $sequence)
 * @method static Product[]|Proxy[]                 findBy(array $attributes)
 * @method static Product[]|Proxy[]                 randomRange(int $min, int $max, array $attributes = [])
 * @method static Product[]|Proxy[]                 randomSet(int $number, array $attributes = [])
 */
final class ProductFactory 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()->word().random_int(1,999999),
            'description' => self::faker()->text(),
            'blocked' => self::faker()->boolean(),
            'inventory' => self::faker()->numberBetween(0, 99999),
            'baseUnit' => self::faker()->randomElement(['KG', 'SACK', 'STÜCK', '']),
            'buyUnit' => self::faker()->randomElement(['KG', 'MT', 'DOSE', 'SACK', 'STÜCK', '']),
            'sellUnit' => self::faker()->randomElement(['KG', 'MT', 'DOSE', 'SACK', 'STÜCK', '']),
            'trackingCode' => self::faker()->randomElement(['CHARGE', '']),
            'productGroup' => '',
            'customsPosition' => self::faker()->numberBetween(10000000, 99999999),
            'productBookingGroup' => self::faker()->randomElement(['VOLL', '0KOSTEN', '']),
            'vatProductBookingGroup' => self::faker()->randomElement(['VOLL', 'OHNE', '']),
            'createdBy' => UserFactory::random()
        ];
    }

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

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