<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CoreBundle\Fixtures\Factory;

use Doctrine\Common\Collections\ArrayCollection;
use Ferienpass\CoreBundle\Entity\Edition;
use Zenstruck\Foundry\Object\Instantiator;
use Zenstruck\Foundry\ObjectFactory;

class EditionFactory extends ObjectFactory
{
    public function withTasks(array $tasks): static
    {
        return $this->with(['tasks' => new ArrayCollection($tasks)]);
    }

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

    protected function defaults(): array
    {
        return [
            'name' => 'Ferienpass 2021',
            'alias' => 'ferienpass-2021',
        ];
    }

    protected function initialize(): static
    {
        return $this->instantiateWith(Instantiator::withoutConstructor()->alwaysForce('tasks'));
    }
}
