StatefulStatusChanger   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A update() 0 10 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