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

RelayServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the uSilex framework.
5
 *
6
 * (c) Enrico Fagnoni <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
 /**
13
  * This service provider uses http://relayphp.com/2.x to define
14
  * uSilex.httpHandler service.
15
  *
16
  * Add this dependency to your project:
17
  *
18
  * composer require "relay/relay" "2.x@dev"
19
  * 
20
  * USAGE:
21
  *     you need do define the service handler.queue that contains the list
22
  *     of middleware to execute. You can use the id of a service that realize a middleware,
23
  *     a concrete middleware  instance or a callable with the signatur recognized by relay
24
  * 
25
  *     $app->register( new RelayServiceProvider() );
26
  *     $app['handler.queue'] = [
27
  *         'a_middleware_service_id',      // should be defined $app['a_middleware_service_id']
28
  *         new MyMiddleware(),             // a class that implements PSR-15 Middleware interface
29
  *         function( $request, $next ){}   // a closure
30
  *     ];
31
  * 
32
  */
33
namespace uSilex\Provider\Psr15;
34
35
use Pimple\Container;
36
use Pimple\ServiceProviderInterface;
37
use Relay\Relay;
38
39
40
class RelayServiceProvider implements ServiceProviderInterface
41
{
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function register(Container $app)
46
    {        
47
        $app['handler.queue']= function($app) {return [];};
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

47
        $app['handler.queue']= function(/** @scrutinizer ignore-unused */ $app) {return [];};

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...
48
        
49
        $app['uSilex.httpHandler'] = function($app) {
50
                     
51
            $resolver = function ($entry) use($app){
52
                return is_string($entry)?$app[$entry]:$entry;
53
            };
54
                       
55
            return new Relay($app['handler.queue'], $resolver);
56
        };
57
    }
58
    
59
}
60