detectCurrentStateName()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Metabor\Statemachine\Factory;
4
5
use MetaborStd\Statemachine\Factory\StateNameDetectorInterface;
6
use MetaborStd\Statemachine\StatefulInterface;
7
8
/**
9
 * @author otischlinger
10
 */
11
class StatefulStateNameDetector implements StateNameDetectorInterface
12
{
13
    /**
14
     * @see \MetaborStd\Statemachine\Factory\StateNameDetectorInterface::detectCurrentStateName()
15
     */
16 2
    public function detectCurrentStateName($subject)
17
    {
18 2
        if ($subject instanceof StatefulInterface) {
19 1
            return $subject->getCurrentStateName();
20
        } else {
21 1
            throw new \InvalidArgumentException('Subject has to implement the StatefulInterface!');
22
        }
23
    }
24
}
25