Completed
Branch master (df0330)
by Gabriel
08:50 queued 06:43
created

DelegatingLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 5 1
A transformCollection() 0 7 1
1
<?php
2
3
namespace Nip\Router\Loader;
4
5
use Symfony\Component\Config\Loader\DelegatingLoader as SymfonyDirectoryLoader;
6
use Symfony\Component\Routing\RouteCollection;
7
8
/**
9
 * Class DelegatingLoader
10
 * @package Nip\Router\Loader
11
 */
12
class DelegatingLoader extends SymfonyDirectoryLoader
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function load($file, $type = null)
18
    {
19
        $collection = parent::load($file, $type);
20
        return $this->transformCollection($collection);
21
    }
22
23
    /**
24
     * @param RouteCollection $symfonyCollection
25
     * @return \Nip\Router\RouteCollection
26
     */
27
    protected function transformCollection(RouteCollection $symfonyCollection)
28
    {
29
        $collection = new \Nip\Router\RouteCollection();
30
        $collection->addCollection($symfonyCollection);
0 ignored issues
show
Documentation introduced by
$symfonyCollection is of type object<Symfony\Component\Routing\RouteCollection>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
32
        return $collection;
33
    }
34
}
35