Conditions | 6 |
Paths | 14 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function evaluate(array $expectations, array $outcomes): array |
||
28 | { |
||
29 | $statuses = []; |
||
30 | |||
31 | foreach ($expectations as $index => $expectation) { |
||
32 | $statuses[$index] = new Failure("Failed $expectation"); |
||
33 | } |
||
34 | |||
35 | foreach ($outcomes as $outcome) { |
||
36 | $isHandled = false; |
||
37 | |||
38 | foreach ($expectations as $index => $expectation) { |
||
39 | if ($expectation->handles($outcome)) { |
||
40 | $statuses[$index] = $expectation->handle($outcome); |
||
41 | $isHandled = true; |
||
42 | } |
||
43 | } |
||
44 | |||
45 | if (!$isHandled) { |
||
46 | $statuses[] = new Failure("Unhandled $outcome"); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | return $statuses; |
||
51 | } |
||
53 |