Request::authorize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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