Test Failed
Push — master ( 0d2a65...c3aac2 )
by Enrico
02:39
created

MiddlewaresServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 15
dl 0
loc 37
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 34 1
1
<?php
2
namespace examples\routing;
3
use Pimple\ServiceProviderInterface;
4
use Pimple\Container;
5
use Aura\Router\RouterContainer;
6
use Middlewares\AuraRouter;
7
use Middlewares\RequestHandler;
8
use Middlewares\ErrorHandler;
9
10
/**
11
 * this configuration reuse middleware and other
12
 * components available from https://github.com/middlewares project
13
 */
14
class MiddlewaresServiceProvider implements ServiceProviderInterface
15
{
16
17
    public function register(Container $app)
18
    {
19
            
20
        // Error handler middleware configuration
21
        // from: https://github.com/middlewares/error-handler
22
        $app['errorHandlingMiddleware'] = function() {
23
            return (new ErrorHandler())->catchExceptions(true);
24
        };
25
        
26
        
27
        // aura routing middleware configuration
28
        // from: https://github.com/middlewares/aura-router
29
        $app['basepath'] = '/';
30
        $app['auraRouterMiddleware'] = function($app) {
31
            $routeContainer =  new RouterContainer($app['basepath']);
32
            $routeMap = $routeContainer->getMap();
33
           
34
            include "routes.php";
35
36
            return new AuraRouter($routeContainer);
37
        };
38
        
39
        
40
        // register the RequestHandler
41
        // from https://github.com/middlewares/request-handler
42
        $app['requestHandlerMiddleware'] = function($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

42
        $app['requestHandlerMiddleware'] = function(/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
            return new RequestHandler();
44
        }; 
45
        
46
        // define middleware queue
47
        $app['handler.queue'] = [
48
            'errorHandlingMiddleware',
49
            'auraRouterMiddleware',
50
            'requestHandlerMiddleware'
51
        ];
52
        
53
    }
54
}
55