AbstractNamedProcessDetector   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 49
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
detectProcessName() 0 1 ?
A __construct() 0 4 1
A addProcess() 0 4 1
A hasProcess() 0 4 1
A detectProcess() 0 6 1
1
<?php
2
3
namespace Metabor\Statemachine\Factory;
4
5
use Metabor\NamedCollection;
6
use MetaborStd\Statemachine\Factory\ProcessDetectorInterface;
7
use MetaborStd\Statemachine\ProcessInterface;
8
9
/**
10
 * @author otischlinger
11
 */
12
abstract class AbstractNamedProcessDetector implements ProcessDetectorInterface
13
{
14
    /**
15
     * @var NamedCollection
16
     */
17
    private $processes;
18
19
    /**
20
     * AbstractNamedProcessDetector constructor.
21
     */
22 1
    public function __construct()
23
    {
24 1
        $this->processes = new NamedCollection();
25 1
    }
26
27
    /**
28
     * @param object $subject
29
     * @return string
30
     */
31
    abstract protected function detectProcessName($subject);
32
33
    /**
34
     * @param ProcessInterface $process
35
     */
36 1
    public function addProcess(ProcessInterface $process)
37
    {
38 1
        $this->processes->add($process);
39 1
    }
40
41
    /**
42
     * @param string $name
43
     * @return bool
44
     */
45
    public function hasProcess($name)
46
    {
47
        return $this->processes->has($name);
48
    }
49
50
    /**
51
     * @param object $subject
52
     * @return ProcessInterface
53
     */
54 1
    public function detectProcess($subject)
55
    {
56 1
        $name = $this->detectProcessName($subject);
57
58 1
        return $this->processes->get($name);
59
    }
60
}
61