-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #839 from ergebnis/feature/helper
Enhancement: Pull in `Helper` from `ergebnis/test-util`
- Loading branch information
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2018-2021 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/composer-normalize | ||
*/ | ||
|
||
namespace Ergebnis\Composer\Normalize\Test\Util; | ||
|
||
use Faker\Factory; | ||
use Faker\Generator; | ||
|
||
trait Helper | ||
{ | ||
final protected static function faker(string $locale = 'en_US'): Generator | ||
{ | ||
/** | ||
* @var array<string, Generator> | ||
*/ | ||
static $fakers = []; | ||
|
||
if (!\array_key_exists($locale, $fakers)) { | ||
$faker = Factory::create($locale); | ||
|
||
$faker->seed(9001); | ||
|
||
$fakers[$locale] = $faker; | ||
} | ||
|
||
return $fakers[$locale]; | ||
} | ||
} |