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

RouterTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 20
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A group() 0 10 4
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