Failed Conditions
Branch master (e37483)
by Maximo
06:09
created

RouterProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCollections() 0 9 2
A getRoutes() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Providers;
6
7
use function Canvas\Core\appPath;
8
use Baka\Router\Providers\RouterProvider as BakaRouterProvider;
9
10
class RouterProvider extends BakaRouterProvider
11
{
12
    /**
13
     * @inheritDoc
14
     *
15
     * @return array
16
     */
17
    protected function getCollections(): array
18
    {
19
        $routerCollections = [];
20
21
        foreach ($this->getRoutes() as $routePath) {
22
            array_push($routerCollections, ...require($routePath));
23
        }
24
25
        return $routerCollections;
26
    }
27
28
    /**
29
     * Returns the array for all the routes on this system.
30
     *
31
     * @return array
32
     */
33
    protected function getRoutes(): array
34
    {
35
        $path = appPath('api/routes');
36
37
        $routes = [
38
            'api' => $path . '/api.php',
39
        ];
40
41
        return $routes;
42
    }
43
}
44