diff --git a/README.md b/README.md index d55b94b..7e05c8e 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ echo $User->last_name; // 'Doe' ### Custom Class Instantiation -To customize instantiation, override the `instantiate()` method in your factory and call it within `make()`. +To customize instantiation, override the `make()` method. ```php class User @@ -118,15 +118,10 @@ class UserFactory ]; } - private function instantiate(): User + private function make(): User { return new User($this->context['first_name'], $this->context['last_name']); } - - public function make(): User - { - return $this->instantiate(); - } } $User = UserFactory::factory()->make(); diff --git a/tests/Unit/OverrideExample/UserFactory.php b/tests/Unit/OverrideExample/UserFactory.php index 82ed729..8f0efbb 100644 --- a/tests/Unit/OverrideExample/UserFactory.php +++ b/tests/Unit/OverrideExample/UserFactory.php @@ -16,13 +16,8 @@ private function definition(): array ]; } - private function instantiate() - { - return new User($this->context['first_name'], $this->context['last_name']); - } - public function make(): User { - return $this->instantiate(); + return new User($this->context['first_name'], $this->context['last_name']); } } \ No newline at end of file