Test Failed
Push — master ( cafe13...7a2929 )
by Enrico
02:56
created

ServiceConfiguration   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
4
use Pimple\ServiceProviderInterface;
5
use Pimple\Container;
6
use Aura\Router\RouterContainer;
7
use Middlewares\AuraRouter;
8
use Middlewares\RequestHandler;
9
use Middlewares\ErrorHandler;
10
11
/**
12
 * this configuration reuse middleware and other
13
 * components directry from the network
14
 */
15
class ServiceConfiguration implements ServiceProviderInterface
16
{
17
18
    public function register(Container $app)
19
    {
20
            
21
        // Error handler middleware configuration
22
        // from: https://github.com/middlewares/error-handler
23
        $app['errorHandlingMiddleware'] = function() {
24
            return (new ErrorHandler())->catchExceptions(true);
25
        };
26
        
27
        
28
        // aura routing middleware configuration
29
        // from: https://github.com/middlewares/aura-router
30
        $app['basepath'] = '/';
31
        $app['auraRouterMiddleware'] = function($app) {
32
            $routeContainer =  new RouterContainer($app['basepath']);
33
            $routeMap = $routeContainer->getMap();
34
           
35
            include "routes.php";
36
37
            return new AuraRouter($routeContainer);
38
        };
39
        
40
        
41
        // register the RequestHandler
42
        // from https://github.com/middlewares/request-handler
43
        $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

43
        $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...
44
            return new RequestHandler();
45
        }; 
46
        
47
        // define middleware queue
48
        $app['handler.queue'] = [
49
            'errorHandlingMiddleware',
50
            'auraRouterMiddleware',
51
            'requestHandlerMiddleware'
52
        ];
53
        
54
    }
55
}
56