UrlGeneratorTrait::registerUrlGenerator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 1
f 0
ccs 3
cts 3
cp 1
crap 1
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 3
    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? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        $this->/** @scrutinizer ignore-call */ 
24
               getContainer()->singleton('url', function () {
Loading history...
24 1
            $router = $this->getContainer()->get('router');
25 1
            return $router->getGenerator();
26 3
        });
27 3
    }
28
}
29