Passed
Branch master (64a50e)
by Brian
02:57
created

RouteServiceProvider::configureRateLimiting()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 3
cp 0.6667
crap 1.037
rs 10
1
<?php
2
3
namespace App\Providers;
4
5
use Illuminate\Cache\RateLimiting\Limit;
6
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
7
use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\RateLimiter;
9
use Illuminate\Support\Facades\Route;
10
11
class RouteServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * The path to the "home" route for your application.
15
     *
16
     * This is used by Laravel authentication to redirect users after login.
17
     *
18
     * @var string
19
     */
20
    public const HOME = '/home';
21
22
    /**
23
     * If specified, this namespace is automatically applied to your controller routes.
24
     *
25
     * In addition, it is set as the URL generator's root namespace.
26
     *
27
     * @var string
28
     */
29
    protected $namespace;
30
31
    /**
32
     * Define your route model bindings, pattern filters, etc.
33
     */
34 99
    public function boot()
35
    {
36 99
        $this->configureRateLimiting();
37
38 99
        $this->routes(function () {
39 99
            Route::middleware('web')
40 99
                ->group(base_path('routes/web.php'))
41
            ;
42
43 99
            Route::prefix('admin')
44 99
                ->as('admin.')
45 99
                ->middleware('web')
46 99
                ->group(base_path('routes/admin.php'))
47
            ;
48
49 99
            Route::prefix('api')
50 99
                ->middleware('api')
51 99
                ->group(base_path('routes/api.php'))
52
            ;
53
        });
54
    }
55
56
    /**
57
     * Configure the rate limiters for the application.
58
     */
59 99
    protected function configureRateLimiting()
60
    {
61 99
        RateLimiter::for('api', function (Request $request) {
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

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

61
        RateLimiter::for('api', function (/** @scrutinizer ignore-unused */ Request $request) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
            return Limit::perMinute(60);
63
        });
64
    }
65
}
66