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