GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RouterServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Router;
4
5
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
6
use Nip\Router\Generator\UrlGenerator;
7
8
/**
9
 * Class MailServiceProvider
10
 * @package Nip\Mail
11
 */
12
class RouterServiceProvider extends AbstractSignatureServiceProvider
13
{
14
15
    /**
16
     * @inheritdoc
17
     */
18
    public function register()
19
    {
20
        $this->registerRouter();
21
22
        $this->registerUrlGenerator();
23
    }
24
25
    protected function registerRouter()
26
    {
27
        $this->getContainer()->share('router', self::newRouter());
28
    }
29
30
    /**
31
     * @return Router
32
     */
33
    public static function newRouter()
34
    {
35
        return new Router();
36
    }
37
38
    /**
39
     * Register the URL generator service.
40
     *
41
     * @return void
42
     */
43
    protected function registerUrlGenerator()
44
    {
45
        $this->getContainer()->share('url', function () {
46
            $routes = app('router')->getRoutes();
47
48
            // The URL generator needs the route collection that exists on the router.
49
            // Keep in mind this is an object, so we're passing by references here
50
            // and all the registered routes will be available to the generator.
51
            app()->share('routes', $routes);
52
53
            $url = new UrlGenerator(
54
                $routes,
55
                request()
56
            );
57
58
            // If the route collection is "rebound", for example, when the routes stay
59
            // cached for the application, we will need to rebind the routes on the
60
            // URL generator instance so it has the latest version of the routes.
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
61
//            $app->rebinding('routes', function ($app, $routes) {
62
//                $app['url']->setRoutes($routes);
63
//            });
64
            return $url;
65
        });
66
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71
    public function provides()
72
    {
73
        return ['router', 'url'];
74
    }
75
}
76