ChainProcessDecorator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace SRIO\ChainOfResponsibility;
4
5
final class ChainProcessDecorator implements ChainProcessInterface
6
{
7
    /**
8
     * @var ChainProcessInterface
9
     */
10
    private $process;
11
12
    /**
13
     * @var ChainProcessInterface
14
     */
15
    private $nextProcess;
16
17
    /**
18
     * @param ChainProcessInterface $process
19
     * @param ChainProcessInterface $nextProcess
20
     */
21 7
    public function __construct(ChainProcessInterface $process, ChainProcessInterface $nextProcess = null)
22
    {
23 7
        $this->process = $process;
24 7
        $this->nextProcess = $nextProcess;
25 7
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 7
    public function execute(ChainContext $context)
31
    {
32 7
        $this->process->execute($context);
33
34 7
        if (null !== $this->nextProcess) {
35 5
            $this->nextProcess->execute($context);
36 5
        }
37 7
    }
38
}
39