Test Setup Failed
Push — master ( ec0b1d...f71903 )
by Gabriel
02:16 queued 11s
created

UrlGeneratorTrait::getRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Router\ServiceProvider\Traits;
4
5
use Nip\Request;
6
use Nip\Router\Generator\UrlGenerator;
7
use Nip\Router\RequestContext;
8
9
/**
10
 * Trait UrlGeneratorTrait
11
 * @package Nip\Router\ServiceProvider\Traits
12
 */
13
trait UrlGeneratorTrait
14
{
15
16
    /**
17
     * Register the URL generator service.
18
     *
19
     * @return void
20
     */
21 1
    public function registerUrlGenerator()
22
    {
23
        $this->getContainer()->singleton('url', function () {
0 ignored issues
show
Bug introduced by
It seems like getContainer() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
24 1
            $router = $this->getContainer()->get('router');
0 ignored issues
show
Bug introduced by
It seems like getContainer() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
25 1
            return $router->getGenerator();
26 1
        });
27 1
    }
28
}
29