UrlGeneratorTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 4
dl 0
loc 13
rs 10
c 1
b 1
f 0
ccs 3
cts 3
cp 1
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A registerUrlGenerator() 0 5 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