Total Complexity | 5 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class Handler implements HandlerInterface |
||
12 | { |
||
13 | /** @var HandlerInterface|null */ |
||
14 | protected HandlerInterface|null $nextHandler = null; |
||
15 | |||
16 | /** |
||
17 | * @param HandlerInterface $handler |
||
18 | * @return HandlerInterface |
||
19 | */ |
||
20 | public function next(HandlerInterface $handler): HandlerInterface |
||
21 | { |
||
22 | $this->nextHandler = $handler; |
||
23 | |||
24 | return $handler; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param mixed $message |
||
29 | * @param array $context |
||
30 | * @return string |
||
31 | */ |
||
32 | public function handler(mixed $message, array $context = []): string |
||
33 | { |
||
34 | if ($this->nextHandler instanceof HandlerInterface) { |
||
35 | return $this->nextHandler->handler($message, $context); |
||
36 | } |
||
37 | |||
38 | $clear = addslashes($this->clearEof($message)); |
||
39 | |||
40 | return sprintf('"%s" {}', $clear); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param string $value |
||
45 | * @return string |
||
46 | */ |
||
47 | protected function clearEof(string $value): string |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param $value |
||
54 | * @return string |
||
55 | */ |
||
56 | protected function encode($value): string |
||
59 | } |
||
60 | } |
||
61 |