Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Commit

Permalink
Added getGeneratorInstance method to get unique instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Alireza Josheghani committed Feb 4, 2017
1 parent 351b84f commit 7917e59
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/Faker.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@
*
* @author Alireza Josheghani <josheghani.dev@gmail.com>
* @since 12 Dec 2016
* @property string $fullname
* @property string $firstname
* @property string $lastname
* @property integer $telephone
* @property integer $age
* @property string $email
* @property string $domain
* @property string $website
* @property string $pageUrl
* @property string $company
* @property string $mobile
* @property string $address
* @property string $city
* @property string $meliCode
* @method static fullname()
* @method static firstname()
* @method static lastname()
Expand All @@ -38,6 +24,17 @@
*/
class Faker
{
/**
* Get Generator instance
*
* @author Alireza Josheghani <josheghani.dev@gmail.com>
* @since 4 Feb 2017
* @return Generator
*/
public function getGeneratorInstance()
{
return new Generator();
}

/**
* Call method from magic method
Expand All @@ -49,9 +46,7 @@ class Faker
*/
public function __get($method)
{
$instance = new Generator();

return $instance->$method();
return static::getGeneratorInstance()->$method();
}

/**
Expand All @@ -63,9 +58,7 @@ public function __get($method)
*/
public static function __callStatic($method, $args)
{
$instance = new Generator();

return $instance->$method(...$args);
return static::getGeneratorInstance()->$method(...$args);
}

}

0 comments on commit 7917e59

Please sign in to comment.