| Total Complexity | 7 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class CategoryFixturePool |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var CategoryFixture[] |
||
| 14 | */ |
||
| 15 | private $categoryFixtures = []; |
||
| 16 | |||
| 17 | 7 | public function add(CategoryInterface $category, string $key = null): void |
|
| 23 | } |
||
| 24 | 7 | } |
|
| 25 | |||
| 26 | /** |
||
| 27 | * Returns category fixture by key, or last added if key not specified |
||
| 28 | * |
||
| 29 | * @param int|string|null $key |
||
| 30 | * @return CategoryFixture |
||
| 31 | */ |
||
| 32 | 7 | public function get($key = null): CategoryFixture |
|
| 33 | { |
||
| 34 | 7 | if ($key === null) { |
|
| 35 | 4 | $key = \array_key_last($this->categoryFixtures); |
|
| 36 | } |
||
| 37 | 7 | if ($key === null || !array_key_exists($key, $this->categoryFixtures)) { |
|
| 38 | 4 | throw new \OutOfBoundsException('No matching category found in fixture pool'); |
|
| 39 | } |
||
| 40 | 3 | return $this->categoryFixtures[$key]; |
|
| 41 | } |
||
| 42 | |||
| 43 | 3 | public function rollback(): void |
|
| 47 | 3 | } |
|
| 48 | } |
||
| 49 |