Completed
Push — master ( d41a26...1c5167 )
by Gabriel
04:02
created

Router   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 13
dl 0
loc 46
rs 10
c 2
b 0
f 1
ccs 5
cts 9
cp 0.5556
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequest() 0 3 1
A __construct() 0 12 4
A setRequest() 0 3 1
1
<?php
2
3
namespace Nip\Router;
4
5
use Nip\Request;
6
use Nip\Router\Generator\CompiledUrlGenerator;
7
use Nip\Router\Generator\UrlGenerator;
8
use Nip\Router\Legacy\Router\Traits\HasMatcherTrait as LegacyHasMatcherTrait;
9
use Nip\Router\Router\Traits\HasCurrentRouteTrait;
10
use Nip\Router\Router\Traits\HasGeneratorTrait;
11
use Nip\Router\Router\Traits\HasMatcherTrait;
12
use Nip\Router\Router\Traits\HasRouteCollectionTrait;
13
use Psr\Log\LoggerInterface;
14
use Symfony\Component\Config\Loader\LoaderInterface;
15
use Symfony\Component\Routing\Loader\ClosureLoader;
16
17
/**
18
 * Class Router
19
 * @package Nip\Router
20
 *
21
 * @method CompiledUrlGenerator getGenerator()
22
 */
23
class Router extends \Symfony\Component\Routing\Router
24
{
25
    use LegacyHasMatcherTrait;
0 ignored issues
show
Bug introduced by
The trait Nip\Router\Legacy\Router\Traits\HasMatcherTrait requires the property $attributes which is not provided by Nip\Router\Router.
Loading history...
26
27
    use HasRouteCollectionTrait;
28
    use HasCurrentRouteTrait;
29
    use HasGeneratorTrait;
30
    use HasMatcherTrait;
31
32
    /**
33
     * @inheritdoc
34
     */
35 24
    public function __construct(
36
        LoaderInterface $loader = null,
37
        $resource = null,
38
        array $options = [],
39
        RequestContext $context = null,
40
        LoggerInterface $logger = null
41
    ) {
42 24
        $loader = $loader ?: new ClosureLoader();
43 24
        $options['generator_class'] = isset($options['generator_class']) ? $options['generator_class'] : CompiledUrlGenerator::class;
44
//        $options['generator_base_class'] = isset($options['generator_base_class']) ? $options['generator_base_class'] : UrlGenerator::class;
45 24
        $context = $context ?: new RequestContext();
46 24
        return parent::__construct($loader, $resource, $options, $context, $logger);
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::__construct($loa...ons, $context, $logger) targeting Symfony\Component\Routing\Router::__construct() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
47
    }
48
49
    /**
50
     * @var \Nip\Request
51
     */
52
    protected $request;
53
54
55
    /**
56
     * @return Request
57
     */
58
    public function getRequest()
59
    {
60
        return $this->request;
61
    }
62
63
    /**
64
     * @param mixed $request
65
     */
66
    public function setRequest($request)
67
    {
68
        $this->request = $request;
69
    }
70
}
71