ProcessCollection::getProcesses()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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