Request   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A getRouteParameter() 0 4 1
1
<?php
2
3
namespace App\Http\Requests;
4
5
use Route;
6
use Illuminate\Foundation\Http\FormRequest;
7
use Illuminate\Contracts\Validation\Validator;
8
9
abstract class Request extends FormRequest
10
{
11
    /**
12
     * Determine if the user is authorized to make this request.
13
     *
14
     * @return bool
15
     */
16
    public function authorize()
17
    {
18
        return true;
19
    }
20
21
    /**
22
     * Handle a failed validation attempt.
23
     *
24
     * @param  $validator
25
     *
26
     * @return mixed
27
     */
28
    protected function failedValidation(Validator $validator)
29
    {
30
        flash()->error(trans('validation.failedForm'));
0 ignored issues
show
Bug introduced by
It seems like trans('validation.failedForm') targeting trans() can also be of type object<Symfony\Component...on\TranslatorInterface>; however, Laracasts\Flash\FlashNotifier::error() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
31
32
        parent::failedValidation($validator);
33
    }
34
35
    /**
36
     * Get a parameter of the current route.
37
     *
38
     * @param $key
39
     *
40
     * @return object|string
41
     */
42
    protected function getRouteParameter($key)
43
    {
44
        return Route::getCurrentRoute()->parameter($key);
45
    }
46
}
47