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

NextTrait::next()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 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