SearchBlockerRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A messages() 0 6 1
A rules() 0 4 1
A authorize() 0 7 2
1
<?php
2
3
namespace jeremykenedy\LaravelBlocker\App\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
0 ignored issues
show
Bug introduced by
The type Illuminate\Foundation\Http\FormRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
class SearchBlockerRequest extends FormRequest
8
{
9
    /**
10
     * Determine if the user is authorized to make this request.
11
     *
12
     * @return bool
13
     */
14
    public function authorize()
15
    {
16
        if (config('laravelblocker.rolesEnabled')) {
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

16
        if (/** @scrutinizer ignore-call */ config('laravelblocker.rolesEnabled')) {
Loading history...
17
            return config('laravelblocker.rolesMiddlware');
18
        }
19
20
        return true;
21
    }
22
23
    /**
24
     * Get the validation rules that apply to the request.
25
     *
26
     * @return array
27
     */
28
    public function rules()
29
    {
30
        return [
31
            'blocked_search_box' => 'required|string|max:255',
32
        ];
33
    }
34
35
    /**
36
     * Get the error messages for the defined validation rules.
37
     *
38
     * @return array
39
     */
40
    public function messages()
41
    {
42
        return [
43
            'blocked_search_box.required' => trans('laravelblocker::laravelblocker.search.required'),
0 ignored issues
show
Bug introduced by
The function trans was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

43
            'blocked_search_box.required' => /** @scrutinizer ignore-call */ trans('laravelblocker::laravelblocker.search.required'),
Loading history...
44
            'blocked_search_box.string'   => trans('laravelblocker::laravelblocker.search.string'),
45
            'blocked_search_box.max'      => trans('laravelblocker::laravelblocker.search.max'),
46
        ];
47
    }
48
}
49