RouteServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 26.23 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 5 1
A map() 0 5 1
A mapWebRoutes() 8 8 1
A mapApiRoutes() 8 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
namespace App\Providers;
3
use Illuminate\Routing\Router;
4
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
5
6
/**
7
 * Class RouteServiceProvider
8
 * @package App\Providers
9
 */
10
class RouteServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * This namespace is applied to your controller routes.
14
     *
15
     * In addition, it is set as the URL generator's root namespace.
16
     *
17
     * @var string
18
     */
19
    protected $namespace = 'App\Http\Controllers';
20
    /**
21
     * Define your route model bindings, pattern filters, etc.
22
     *
23
     * @param  \Illuminate\Routing\Router  $router
24
     * @return void
25
     */
26
    public function boot(Router $router)
27
    {
28
        //
29
        parent::boot($router);
30
    }
31
    /**
32
     * Define the routes for the application.
33
     *
34
     * @param  \Illuminate\Routing\Router  $router
35
     * @return void
36
     */
37
    public function map(Router $router)
38
    {
39
        $this->mapWebRoutes($router);
40
        $this->mapApiRoutes($router);
41
    }
42
    /**
43
     * Define the "web" routes for the application.
44
     *
45
     * These routes all receive session state, CSRF protection, etc.
46
     *
47
     * @param  \Illuminate\Routing\Router  $router
48
     * @return void
49
     */
50 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...
51
    {
52
        $router->group([
53
            'namespace' => $this->namespace, 'middleware' => 'web',
54
        ], function ($router) {
55
            require app_path('Http/routes.php');
56
        });
57
    }
58
59
    /**
60
     * @param Router $router
61
     */
62 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...
63
    {
64
        $router->group([
65
            'namespace' => $this->namespace, 'middleware' => 'web',
66
        ], function ($router) {
67
            require app_path('Http/routes_api.php');
68
        });
69
    }
70
}