Completed
Push — master ( 976ce5...4a7070 )
by Christopher
06:24
created

RoutesInspector   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 31
c 0
b 0
f 0
ccs 18
cts 18
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 3
B inspect() 0 20 6
1
<?php
2
3
namespace Phwoolcon\TestStarter\TestCase\Generator;
4
5
use Phalcon\Mvc\Router\Route;
6
use Phwoolcon\Router;
7
8
class RoutesInspector extends Router
9
{
10
11 2
    public function __construct($file)
12
    {
13 2
        $this->_routes = [];
14 2
        $routes = is_file($file) ? include $file : [];
15 2
        is_array($routes) && $this->addRoutes($routes);
16 2
    }
17
18 2
    public function inspect()
19
    {
20 2
        $this->splitRoutes();
21 2
        $testCases = [];
22 2
        foreach ($this->exactRoutes as $method => $routes) {
23 2
            if ($method == 'HEAD') {
24 2
                continue;
25
            }
26
            /* @var Route $route */
27 2
            foreach ($routes as $route) {
28 2
                $paths = $route->getPaths();
29 2
                $controller = $paths['controller'];
30 2
                $action = $paths['action'];
31 2
                if (is_string($controller) && is_callable([$controller, $action])) {
32 2
                    $testCases[$controller][$action][$method][] = $route->getPattern();
33
                }
34
            }
35
        }
36 2
        return $testCases;
37
    }
38
}
39