OneOrNoneActiveTransition   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 19
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A selectTransition() 0 13 3
1
<?php
2
3
namespace Metabor\Statemachine\Factory\TransitionSelector;
4
5
use MetaborStd\Statemachine\Factory\TransitionSelectorInterface;
6
7
/**
8
 * @author otischlinger
9
 */
10
class OneOrNoneActiveTransition implements TransitionSelectorInterface
11
{
12
    /**
13
     * @see \MetaborStd\Statemachine\Factory\TransitionSelectorInterface::selectTransition()
14
     */
15 10
    public function selectTransition(\Traversable $transitions)
16
    {
17 10
        $transitions = iterator_to_array($transitions);
18
19 10
        switch (count($transitions)) {
20 10
            case 0:
21 3
                return;
22 10
            case 1:
23 8
                return reset($transitions);
24 2
            default:
25 2
                throw new \RuntimeException('More than one transition is active!');
26 2
        }
27
    }
28
}
29