| Total Complexity | 9 |
| Total Lines | 83 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class FixtureManager |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var string $folder |
||
| 14 | */ |
||
| 15 | protected $folder; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var $faker |
||
|
|
|||
| 19 | */ |
||
| 20 | protected static $faker; |
||
| 21 | |||
| 22 | public function __construct(string $folder) |
||
| 23 | { |
||
| 24 | if (! FileManager::exists($folder)) { |
||
| 25 | throw new \InvalidArgumentException('No such folder: ' . $folder); |
||
| 26 | } |
||
| 27 | |||
| 28 | $this->folder = $folder; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Returns a fixture |
||
| 33 | * |
||
| 34 | * @access public |
||
| 35 | * @param string $code |
||
| 36 | * @param array $additional Default: [] |
||
| 37 | * @return array |
||
| 38 | */ |
||
| 39 | public function make(string $code, array $additional = []): array |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * makeMany. |
||
| 60 | * |
||
| 61 | * @access public |
||
| 62 | * @param string $code |
||
| 63 | * @param int $quantity |
||
| 64 | * @param array $additional Default: [] |
||
| 65 | * @return array |
||
| 66 | */ |
||
| 67 | public function makeMany(string $code, int $quantity, array $additional = []): array |
||
| 68 | { |
||
| 69 | $data = []; |
||
| 70 | |||
| 71 | while ($quantity > 0) { |
||
| 72 | $data[] = $this->make($code, $additional); |
||
| 73 | |||
| 74 | --$quantity; |
||
| 75 | } |
||
| 76 | |||
| 77 | return $data; |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * getFaker. |
||
| 82 | * |
||
| 83 | * @access public |
||
| 84 | * @return Generator |
||
| 85 | */ |
||
| 86 | public static function getFaker(): Generator |
||
| 93 | } |
||
| 94 | } |
||
| 95 |