Conditions | 6 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
40 | public function selectTransition(\Traversable $transitions) |
||
41 | { |
||
42 | $bestTransitions = array(); |
||
43 | $bestWeight = null; |
||
44 | foreach ($transitions as $transition) { |
||
45 | if ($transition instanceof WeightedInterface) { |
||
46 | $weight = $transition->getWeight(); |
||
47 | $diff = ($weight - $bestWeight); |
||
48 | if (($bestWeight === null) || ($diff >= $this->epsilon)) { |
||
49 | $bestWeight = $weight; |
||
50 | $bestTransitions = array($transition); |
||
51 | } elseif (abs($diff) < $this->epsilon) { |
||
52 | $bestTransitions[] = $transition; |
||
53 | } |
||
54 | } |
||
55 | } |
||
56 | |||
57 | return $this->innerSelector->selectTransition(new \ArrayIterator($bestTransitions)); |
||
58 | } |
||
59 | } |
||
60 |