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

NextTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A next() 0 10 2
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
 * Trait NextTrait
14
 * @package Behavioral\ChainOfResponsibility
15
 */
16
trait NextTrait
17
{
18
19
    /**
20
     * @param string $event
21
     * @param        $chain
22
     */
23
    protected function next(string $event, $chain)
24
    {
25
        $handler = array_shift($chain);
26
27
        if (!isset($handler)) {
28
            return;
29
        }
30
31
        $handler = new $handler();
32
        $handler->request($event, $chain);
33
    }
34
}
35