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