Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 4, 2017
1 parent 56363e4 commit 5c72698
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions src/Illuminate/Foundation/Testing/WithFaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
trait WithFaker
{
/**
* Faker generator instance.
* The Faker instance.
*
* @var \Faker\Generator
*/
protected $faker;

/**
* Setup up faker generator instance.
* Setup up the Faker instance.
*
* @return void
*/
Expand All @@ -25,43 +25,24 @@ protected function setUpFaker()
}

/**
* Get a default faker generator instance or get a new one for given locale.
* Get the default Faker instance for a given locale.
*
* @param string $locale
* @return \Faker\Generator
*/
protected function faker(string $locale = null)
protected function faker($locale = null)
{
if (is_null($locale)) {
return $this->faker;
}

return $this->makeFaker($locale);
}

/**
* Set a new faker generator instance for given locale.
*
* @param string $locale
* @return void
*/
protected function fakerSetLocale(string $locale)
{
$this->faker = $this->makeFaker($locale);
return is_null($locale) ? $this->faker : $this->makeFaker($locale);
}

/**
* Make a faker generator instance for given or default locale.
* Create a Faker instance for the given locale.
*
* @param string $locale
* @return \Faker\Generator
*/
protected function makeFaker(string $locale = null)
protected function makeFaker($locale = null)
{
if (is_null($locale)) {
$locale = Factory::DEFAULT_LOCALE;
}

return Factory::create($locale);
return Factory::create($locale ?? Factory::DEFAULT_LOCALE);
}
}

0 comments on commit 5c72698

Please sign in to comment.