Completed
Push — master ( 0b8c1e...75226e )
by Sergii
05:34
created

RouterTrait::group()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 8
nop 2
crap 20
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: conci
5
 * Date: 10/25/17
6
 * Time: 11:57 AM
7
 */
8
9
namespace sonrac\WAMP\Routers;
10
11
/**
12
 * Trait RouterTrait
13
 * Base router trait
14
 *
15
 * @package sonrac\WAMP\Routers
16
 */
17
trait RouterTrait
18
{
19
    /**
20
     * @var null|\sonrac\WAMP\GroupsConfigInterface[]
21
     */
22
    protected $groups = null;
23
24
    /**
25
     * @inheritDoc
26
     */
27
    public function group(array $config, \Closure $runner)
28
    {
29
        $middleware = isset($config['middleware']) ? explode('|', $config['middleware']) : [];
30
        $namespace = isset($config['namespace']) ? $config['namespace'] : 'App\Controllers\WAMP';
31
32
        $this->groups[] = (object)[
33
            'middleware' => $middleware,
34
            'namespace'  => $namespace,
35
            'prefix'     => isset($config['prefix']) ? $config['prefix'] : '',
36
            'callback'   => $runner
37
        ];
38
    }
39
}
40