FormRequest::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * File copied from Waavi/Sanitizer https://github.com/waavi/sanitizer
4
 * Sanitization functionality to be customized within this project before a 1.0 release.
5
 */
6
7
namespace PerfectOblivion\Valid\Sanitizer\Laravel;
8
9
use PerfectOblivion\Valid\Sanitizer\Sanitizer;
10
use Illuminate\Foundation\Http\FormRequest as LaravelFormRequest;
11
12
class FormRequest extends LaravelFormRequest
13
{
14
    /**
15
     * Sanitize input before validating.
16
     */
17
    public function validate()
18
    {
19
        $this->sanitize();
20
        parent::validate();
0 ignored issues
show
Bug introduced by
The method validate() does not exist on Illuminate\Foundation\Http\FormRequest. Did you maybe mean validated()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
21
    }
22
23
    /**
24
     * Sanitize this request's input.
25
     */
26
    public function sanitize()
27
    {
28
        $this->sanitizer = Sanitizer::make($this->input(), $this->filters());
0 ignored issues
show
Bug introduced by
The property sanitizer does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
The method make() does not seem to exist on object<PerfectOblivion\Valid\Sanitizer\Sanitizer>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        $this->replace($this->sanitizer->sanitize());
30
    }
31
32
    /**
33
     * Filters to be applied to the input.
34
     *
35
     * @return array
36
     */
37
    public function filters()
38
    {
39
        return [];
40
    }
41
42
    /**
43
     * Validation rules to be applied to the input.
44
     *
45
     * @return array
46
     */
47
    public function rules()
48
    {
49
        return [];
50
    }
51
52
    /**
53
     * Determine if the user is authorized to make this request.
54
     *
55
     * @return bool
56
     */
57
    public function authorize()
58
    {
59
        return true;
60
    }
61
}
62