Completed
Push — master ( e89e82...18615b )
by Korotkov
01:55
created

AbstractHandler::message()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @license   https://mit-license.org/ MIT
8
 */
9
10
namespace Behavioral\ChainOfResponsibility;
11
12
/**
13
 * Class AbstractHandler
14
 * @package Behavioral\ChainOfResponsibility
15
 */
16
abstract class AbstractHandler
17
{
18
19
    /**
20
     * @param string $event
21
     * @param        $chain
22
     */
23
    public function request(string $event, $chain): void
24
    {
25
        $this->message($event);
26
        $this->next($event, $chain);
27
    }
28
29
    /**
30
     * @param string $event
31
     * @param        $chain
32
     * @return mixed
33
     */
34
    abstract protected function next(string $event, $chain);
35
36
    /**
37
     * @param string $event
38
     */
39
    protected function message(string $event)
40
    {
41
        if ($event == static::class) {
42
            printf('%s' . PHP_EOL, $event);
43
            return;
44
        }
45
    }
46
}
47