ProcessCollection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 36
c 0
b 0
f 0
ccs 10
cts 14
cp 0.7143
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 15 4
A getProcesses() 0 4 1
1
<?php
2
3
namespace SRIO\ChainOfResponsibility;
4
5
class ProcessCollection
6
{
7
    /**
8
     * @var ChainProcessInterface[]
9
     */
10
    private $processes;
11
12
    /**
13
     * Add a process to the collection.
14
     *
15
     * @param array|ChainProcessInterface $process
16
     */
17 10
    public function add($process)
18
    {
19 10
        if (is_array($process)) {
20 10
            foreach ($process as $p) {
21 9
                $this->add($p);
22 10
            }
23 10
        } elseif (!$process instanceof ChainProcessInterface) {
24
            throw new \RuntimeException(sprintf(
25
                'Expect to be instance of ChainProcessInterface or array but got %s',
26
                get_class($process)
27
            ));
28
        } else {
29 9
            $this->processes[] = $process;
30
        }
31 10
    }
32
33
    /**
34
     * @return ChainProcessInterface[]
35
     */
36 10
    public function getProcesses()
37
    {
38 10
        return $this->processes;
39
    }
40
}
41