From bbea7057f19ddbe65f82d05ffbf8e4574298b2ca Mon Sep 17 00:00:00 2001 From: MartkCz Date: Tue, 16 Apr 2024 17:06:46 +0200 Subject: [PATCH] add FixtureTools::$uniqueFaker --- src/Fixture.php | 10 +++------- src/Utility/FixtureTools.php | 8 +++----- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Fixture.php b/src/Fixture.php index a154be6..d824126 100644 --- a/src/Fixture.php +++ b/src/Fixture.php @@ -18,6 +18,8 @@ abstract class Fixture protected FixtureTools $tools; + protected Faker $uniqueFaker; + protected int|Range|null $repeatLoad = null; abstract public function getKey(): FixtureKey; @@ -29,8 +31,6 @@ abstract public function load(): iterable; final public function init(FixtureTools $tools): void { - $tools = $this->configureTools($tools); - $this->initialize($tools); } @@ -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; } diff --git a/src/Utility/FixtureTools.php b/src/Utility/FixtureTools.php index b1e00b0..fc44fe3 100644 --- a/src/Utility/FixtureTools.php +++ b/src/Utility/FixtureTools.php @@ -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(); } /**