<?php

declare(strict_types=1);

namespace Apexl\Tests\Core\Infrastructure;

use apexl\Io\factories\EntityFactory;

/**
 * @method TestRelatedEntity create(array $attrs = [], bool $store = true)
 */
final readonly class TestRelatedEntityFactory extends EntityFactory
{
    protected function definition(array $attrs): array
    {
        return [
            'name' => $this->nextName(),
        ];
    }

    /** See {@see TestEntityFactory::nextName()} — same unique index, same collisions. */
    private function nextName(): string
    {
        static $next = 0;

        return sprintf('test-related-entity-%d', $next++);
    }
}