Passed
Push — master ( 0e5a66...620416 )
by Rougin
12:10
created

CompositeRouter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 38
c 0
b 0
f 0
ccs 0
cts 12
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A routes() 0 9 1
A merge() 0 7 1
1
<?php
2
3
namespace App\Zapheus;
4
5
use Zapheus\Routing\Router;
6
use Zapheus\Routing\RouterInterface;
7
8
/**
9
 * Route Collection
10
 *
11
 * @package App
12
 * @author  Rougin Royce Gutib <[email protected]>
13
 */
14
class CompositeRouter extends Router
15
{
16
    /**
17
     * Namespace applied to all class-based routes.
18
     *
19
     * @var string
20
     */
21
    protected $namespace = 'App\Zapheus';
22
23
    /**
24
     * Merges the new route instances.
25
     *
26
     * @param  \Zapheus\Routing\RouterInterface $router
27
     * @return self
28
     */
29
    public function merge(RouterInterface $router)
30
    {
31
        $routes = $router->routes();
32
33
        $this->routes = array_merge($this->routes, $routes);
34
35
        return $this;
36
    }
37
38
    /**
39
     * Returns an array of route instances.
40
     *
41
     * @return \Zapheus\Routing\Route[]
42
     */
43
    public function routes()
44
    {
45
        $this->get('/scream', 'GreetController@scream');
46
47
        $this->get('/', 'GreetController@greet');
48
49
        $this->get('/{name}', 'GreetController@greet');
50
51
        return $this->routes;
52
    }
53
}
54