StatefulStatusChanger::update()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 9
cts 9
cp 1
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Metabor\Statemachine\Observer;
4
5
use MetaborStd\Statemachine\StatefulInterface;
6
use MetaborStd\Statemachine\StatemachineInterface;
7
8
/**
9
 * @author otischlinger
10
 */
11
class StatefulStatusChanger implements \SplObserver
12
{
13
    /**
14
     * @see SplObserver::update()
15
     */
16 1
    public function update(\SplSubject $stateMachine)
17
    {
18 1
        if ($stateMachine instanceof StatemachineInterface) {
19 1
            $subject = $stateMachine->getSubject();
20 1
            if ($subject instanceof StatefulInterface) {
21 1
                $stateName = $stateMachine->getCurrentState()->getName();
22 1
                $subject->setCurrentStateName($stateName);
23 1
            }
24 1
        }
25 1
    }
26
}
27