Passed
Push — master ( ec5386...e56f88 )
by Andrey
53s queued 14s
created

RoutesBootloader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A globalMiddleware() 0 11 1
A middlewareGroups() 0 11 1
A defineRoutes() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Application\Bootloader;
6
7
use Spiral\Bootloader\Http\RoutesBootloader as BaseRoutesBootloader;
0 ignored issues
show
Bug introduced by
The type Spiral\Bootloader\Http\RoutesBootloader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Spiral\Cookies\Middleware\CookiesMiddleware;
0 ignored issues
show
Bug introduced by
The type Spiral\Cookies\Middleware\CookiesMiddleware was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Spiral\Csrf\Middleware\CsrfMiddleware;
0 ignored issues
show
Bug introduced by
The type Spiral\Csrf\Middleware\CsrfMiddleware was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Spiral\Debug\StateCollector\HttpCollector;
0 ignored issues
show
Bug introduced by
The type Spiral\Debug\StateCollector\HttpCollector was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Spiral\Http\Middleware\ErrorHandlerMiddleware;
0 ignored issues
show
Bug introduced by
The type Spiral\Http\Middleware\ErrorHandlerMiddleware was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Spiral\Http\Middleware\JsonPayloadMiddleware;
0 ignored issues
show
Bug introduced by
The type Spiral\Http\Middleware\JsonPayloadMiddleware was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Spiral\Router\Bootloader\AnnotatedRoutesBootloader;
0 ignored issues
show
Bug introduced by
The type Spiral\Router\Bootloader\AnnotatedRoutesBootloader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Spiral\Router\Loader\Configurator\RoutingConfigurator;
0 ignored issues
show
Bug introduced by
The type Spiral\Router\Loader\Con...tor\RoutingConfigurator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Spiral\Session\Middleware\SessionMiddleware;
0 ignored issues
show
Bug introduced by
The type Spiral\Session\Middleware\SessionMiddleware was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
/**
18
 * A bootloader that configures the application's routes and middleware.
19
 *
20
 * @link https://spiral.dev/docs/http-routing
21
 */
22
final class RoutesBootloader extends BaseRoutesBootloader
23
{
24
    protected const DEPENDENCIES = [
25
        AnnotatedRoutesBootloader::class,
26
    ];
27
28
    protected function globalMiddleware(): array
29
    {
30
        return [
31
            // If you want to automatically detect the user's locale based on the
32
            // "Accept-Language" header uncomment this middleware and add \Spiral\Bootloader\I18nBootloader
33
            // to the Kernel
34
            // LocaleSelector::class,
35
36
            ErrorHandlerMiddleware::class,
37
            JsonPayloadMiddleware::class,
38
            HttpCollector::class,
39
        ];
40
    }
41
42
    protected function middlewareGroups(): array
43
    {
44
        return [
45
            'web' => [
46
                CookiesMiddleware::class,
47
                SessionMiddleware::class,
48
                CsrfMiddleware::class,
49
                // Uncomment this middleware if you want to authenticate users using cookies
50
                // new Autowire(AuthTransportMiddleware::class, ['transportName' => 'cookie'])
51
            ],
52
            'api' => [
53
                // Uncomment this middleware if you want to authenticate users using headers
54
                // new Autowire(AuthTransportMiddleware::class, ['transportName' => 'header'])
55
            ],
56
        ];
57
    }
58
59
    protected function defineRoutes(RoutingConfigurator $routes): void
60
    {
61
        // Fallback route if no other route matched
62
        // Will show 404 page
63
        // $routes->default('/<path:.*>')
64
        //    ->callable(function (ServerRequestInterface $r, ResponseInterface $response) {
65
        //        return $response->withStatus(404)->withBody('Not found');
66
        //    });
67
    }
68
}
69