RouteServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 12
c 2
b 1
f 0
dl 0
loc 48
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureRateLimiting() 0 4 1
A boot() 0 11 1
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 = 'App\Http\Controllers';
30
31
    /**
32
     * Define your route model bindings, pattern filters, etc.
33
     *
34
     * @return void
35
     */
36
    public function boot()
37
    {
38
        $this->configureRateLimiting();
39
40
        $this->routes(function () {
41
            Route::middleware('web')
42
                ->group(base_path('routes/web.php'));
43
44
            Route::prefix('api')
45
                ->middleware('api')
46
                ->group(base_path('routes/api.php'));
47
        });
48
    }
49
50
    /**
51
     * Configure the rate limiters for the application.
52
     *
53
     * @return void
54
     */
55
    protected function configureRateLimiting()
56
    {
57
        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

57
        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...
58
            return Limit::perMinute(60);
59
        });
60
    }
61
}
62