Completed
Push — dev ( 3f7d36...a5cbf4 )
by Darko
07:14
created

RouteServiceProvider::mapRssRoutes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Providers;
4
5
use Illuminate\Support\Facades\Route;
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
     * @return void
23
     */
24
    public function boot()
25
    {
26
        //
27
28
        parent::boot();
29
    }
30
31
    /**
32
     * Define the routes for the application.
33
     *
34
     * @return void
35
     */
36
    public function map()
37
    {
38
        $this->mapApiRoutes();
39
40
        $this->mapWebRoutes();
41
42
        $this->mapRssRoutes();
43
    }
44
45
    /**
46
     * Define the "web" routes for the application.
47
     *
48
     * These routes all receive session state, CSRF protection, etc.
49
     *
50
     * @return void
51
     */
52
    protected function mapWebRoutes()
53
    {
54
        Route::middleware('web')
55
             ->namespace($this->namespace)
56
             ->group(base_path('routes/web.php'));
0 ignored issues
show
Unused Code introduced by
The call to base_path() has too many arguments starting with 'routes/web.php'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
             ->group(/** @scrutinizer ignore-call */ base_path('routes/web.php'));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
Are you sure the usage of base_path('routes/web.php') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
57
    }
58
59
    /**
60
     * Define the "api" routes for the application.
61
     *
62
     * These routes are typically stateless.
63
     *
64
     * @return void
65
     */
66
    protected function mapApiRoutes()
67
    {
68
        Route::prefix('api')
69
             ->middleware('api')
70
             ->namespace($this->namespace)
71
             ->group(base_path('routes/api.php'));
0 ignored issues
show
Unused Code introduced by
The call to base_path() has too many arguments starting with 'routes/api.php'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
             ->group(/** @scrutinizer ignore-call */ base_path('routes/api.php'));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
Are you sure the usage of base_path('routes/api.php') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
72
    }
73
74
    /**
75
     * Define the "rss" routes for the application.
76
     *
77
     * These routes are typically stateless.
78
     *
79
     * @return void
80
     */
81
    protected function mapRssRoutes()
82
    {
83
        Route::middleware(['api', 'auth:api'])
84
            ->namespace($this->namespace)
85
            ->group(base_path('routes/rss.php'));
0 ignored issues
show
Unused Code introduced by
The call to base_path() has too many arguments starting with 'routes/rss.php'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

85
            ->group(/** @scrutinizer ignore-call */ base_path('routes/rss.php'));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
Are you sure the usage of base_path('routes/rss.php') is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
86
    }
87
}
88