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