Skip to content

Commit

Permalink
add FixtureTools::$uniqueFaker
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed Apr 16, 2024
1 parent b75bd79 commit bbea705
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
10 changes: 3 additions & 7 deletions src/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ abstract class Fixture

protected FixtureTools $tools;

protected Faker $uniqueFaker;

protected int|Range|null $repeatLoad = null;

abstract public function getKey(): FixtureKey;
Expand All @@ -29,8 +31,6 @@ abstract public function load(): iterable;

final public function init(FixtureTools $tools): void
{
$tools = $this->configureTools($tools);

$this->initialize($tools);
}

Expand All @@ -46,14 +46,10 @@ final public function run(): iterable
}
}

public function configureTools(FixtureTools $tools): FixtureTools
{
return $tools;
}

public function initialize(FixtureTools $tools): void
{
$this->faker = $tools->faker;
$this->uniqueFaker = $tools->uniqueFaker;
$this->ref = $tools->ref;
$this->tools = $tools;
}
Expand Down
8 changes: 3 additions & 5 deletions src/Utility/FixtureTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@
final class FixtureTools
{

public readonly Faker $uniqueFaker;

public function __construct(
public readonly ReferenceRepository $ref,
public readonly Faker $faker,
public readonly FixtureConfig $cfg,
)
{
}

public function withUniqueFaker(): self
{
return new self($this->ref, $this->faker->withUnique(), $this->cfg);
$this->uniqueFaker = $this->faker->withUnique();
}

/**
Expand Down

0 comments on commit bbea705

Please sign in to comment.