Completed
Pull Request — master (#3)
by Clayton
06:29
created

FormRequest::rules()   A

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
namespace PerfectOblivion\Valid\Sanitizer\Laravel;
4
5
use Illuminate\Foundation\Http\FormRequest as LaravelFormRequest;
6
7
/**
8
 * File copied from Waavi/Sanitizer https://github.com/waavi/sanitizer
9
 * Sanitization functionality to be customized within this project before a 1.0 release.
10
 */
11
class FormRequest extends LaravelFormRequest
12
{
13
    /**
14
     * Sanitize input before validating.
15
     */
16
    public function validate()
17
    {
18
        $this->sanitize();
19
        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...
20
    }
21
22
    /**
23
     * Sanitize this request's input
24
     */
25
    public function sanitize()
26
    {
27
        $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...
28
        $this->replace($this->sanitizer->sanitize());
29
    }
30
31
    /**
32
     * Filters to be applied to the input.
33
     *
34
     * @return array
35
     */
36
    public function filters()
37
    {
38
        return [];
39
    }
40
41
    /**
42
     * Validation rules to be applied to the input.
43
     *
44
     * @return array
45
     */
46
    public function rules()
47
    {
48
        return [];
49
    }
50
51
    /**
52
     * Determine if the user is authorized to make this request.
53
     *
54
     * @return bool
55
     */
56
    public function authorize()
57
    {
58
        return true;
59
    }
60
}
61