RouteServiceProvider::map()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 14
nc 1
nop 1
dl 0
loc 22
ccs 0
cts 15
cp 0
crap 6
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace Jumilla\Addomnipot\Laravel\Support;
4
5
use Illuminate\Routing\Router;
6
use Illuminate\Support\ServiceProvider;
7
8
abstract class RouteServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap any application services.
12
     *
13
     * @param  \Illuminate\Routing\Router  $router
0 ignored issues
show
Bug introduced by
There is no parameter named $router. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->app->call([$this, 'map']);
19
    }
20
21
    /**
22
     * Define the routes for the addon.
23
     *
24
     * @param  \Illuminate\Routing\Router  $router  (injection)
25
     * @return void
26
     */
27
    public function map(Router $router)
28
    {
29
        $addon = $this->addon();
30
        $config = $addon->config('addon.routes');
31
32
        $attributes = [
33
            'domain' => array_get($config, 'domain', null),
34
            'prefix' => array_get($config, 'prefix', ''),
35
            'namespace' => array_get($config, 'namespace', $addon->phpNamespace().'\\Controllers'),
36
            'middleware' => array_get($config, 'middleware', []),
37
        ];
38
39
        $files = array_map(function ($file) use ($addon) {
40
            return $addon->path($file);
41
        }, array_get($config, 'files', ['classes/Http/routes.php']));
42
43
        $router->group($attributes, function ($router) use ($files) {
44
            foreach ($files as $file) {
45
                require $file;
46
            }
47
        });
48
    }
49
50
    /**
51
     * Get addon.
52
     *
53
     * @return \Jumilla\Addomnipot\Laravel\Addon
54
     */
55
    abstract protected function addon();
56
57
    /**
58
     * Register the service provider.
59
     *
60
     * @return void
61
     */
62
    public function register()
63
    {
64
        //
65
    }
66
67
    /**
68
     * Pass dynamic methods onto the router instance.
69
     *
70
     * @param  string  $method
71
     * @param  array  $parameters
72
     * @return mixed
73
     */
74
    public function __call($method, $parameters)
75
    {
76
        return call_user_func_array([$this->app->make(Router::class), $method], $parameters);
77
    }
78
}
79