RouteServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 88
Duplicated Lines 18.18 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 2
dl 16
loc 88
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A map() 0 6 1
A mapWebRoutes() 8 8 1
A mapApiRoutes() 8 8 1
A mapNoMiddlewareRoutes() 0 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Providers;
4
5
use Illuminate\Routing\Router;
6
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
7
8
class RouteServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * This namespace is applied to your controller routes.
12
     *
13
     * In addition, it is set as the URL generator's root namespace.
14
     *
15
     * @var string
16
     */
17
    protected $namespace = 'App\Http\Controllers';
18
19
    /**
20
     * Define your route model bindings, pattern filters, etc.
21
     *
22
     * @param  \Illuminate\Routing\Router  $router
23
     * @return void
24
     */
25
    public function boot(Router $router)
26
    {
27
        //
28
29
        parent::boot($router);
30
    }
31
32
    /**
33
     * Define the routes for the application.
34
     *
35
     * @param  \Illuminate\Routing\Router  $router
36
     * @return void
37
     */
38
    public function map(Router $router)
39
    {
40
        $this->mapWebRoutes($router);
41
42
        //
43
    }
44
45
    /**
46
     * Define the "web" routes for the application.
47
     *
48
     * These routes all receive session state, CSRF protection, etc.
49
     *
50
     * @param  \Illuminate\Routing\Router  $router
51
     * @return void
52
     */
53 View Code Duplication
    protected function mapWebRoutes(Router $router)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        $router->group([
56
            'namespace' => $this->namespace, 'middleware' => 'web',
57
        ], function ($router) {
58
            require app_path('Http/routes.php');
59
        });
60
    }
61
62
    /**
63
     * Define the "api" routes for the application.
64
     *
65
     * These routes all receive session state, CSRF protection, etc.
66
     *
67
     * @param  \Illuminate\Routing\Router  $router
68
     * @return void
69
     */
70 View Code Duplication
    protected function mapApiRoutes(Router $router)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        $router->group([
73
            'namespace' => $this->namespace, 'middleware' => 'api',
74
        ], function ($router) {
75
            require app_path('Http/routesApi.php');
76
        });
77
    }
78
79
    /**
80
     * Define the no middleware routes for the application.
81
     *
82
     * These routes all receive session state, CSRF protection, etc.
83
     *
84
     * @param  \Illuminate\Routing\Router  $router
85
     * @return void
86
     */
87
    protected function mapNoMiddlewareRoutes(Router $router)
88
    {
89
        $router->group([
90
            'namespace' => $this->namespace,
91
        ], function ($router) {
92
            require app_path('Http/routesNoMiddleware.php');
93
        });
94
    }
95
}
96
97