Completed
Push — master ( 017b80...dacaa0 )
by Vítor
02:05
created

RoutesInspector::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/**
3
 * ZfDebugModule. Console commands and other utilities for debugging ZF2 apps.
4
 *
5
 * @license http://www.opensource.org/licenses/mit-license.html MIT License
6
 * @copyright 2016 Vítor Brandão <[email protected]>
7
 */
8
9
namespace Noiselabs\ZfDebugModule\Util;
10
11
use Zend\Mvc\Router\RouteInterface;
12
use Zend\Mvc\Router\SimpleRouteStack;
13
14
class RoutesInspector
15
{
16
    /**
17
     * @var array
18
     */
19
    private $config;
20
21
    /**
22
     * @var RouteInterface
23
     */
24
    private $router;
25
26
    /**
27
     * RoutesInspector constructor.
28
     *
29
     * @param RouteInterface $router
30
     * @param array          $config
31
     */
32
    public function __construct(RouteInterface $router, array $config)
33
    {
34
        $this->router = $router;
35
        $this->config = $config;
36
    }
37
38
    /**
39
     * @return array|\Traversable
40
     */
41
    public function getRoutes()
42
    {
43
        if ($this->router instanceof SimpleRouteStack) {
44
            /** @var SimpleRouteStack $router */
45
            $router = $this->router;
46
47
            return $router->getRoutes();
48
        }
49
50
        return [];
51
    }
52
}
53