Conditions | 4 |
Paths | 6 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
25 | 5 | public function getMatchingTarget(DestinationInterface $destination) |
|
26 | { |
||
27 | 5 | $sorted = []; |
|
28 | 5 | foreach ($this->targetRepository->findByRoute($destination->getRoute()) as $target) { |
|
29 | 5 | $score = $target->match($destination); |
|
30 | 5 | if (null !== $score) { |
|
31 | 2 | $sorted[$score] = $target; |
|
32 | 2 | } |
|
33 | 5 | } |
|
34 | |||
35 | 5 | if (count($sorted) === 0) { |
|
36 | 3 | throw MatchingException::noTarget(); |
|
37 | } |
||
38 | |||
39 | 2 | ksort($sorted, SORT_DESC); |
|
40 | |||
41 | 2 | return array_shift($sorted); |
|
42 | } |
||
43 | } |
||
44 |