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

DelegatingLoader::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
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