|
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
|
|
|
|