FormRequest::validate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 3
cts 4
cp 0.75
crap 1.0156
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Arcanedev\Sanitizer\Http;
2
3
use Arcanedev\Support\Bases\FormRequest as BaseFormRequest;
4
5
/**
6
 * Class     FormRequest
7
 *
8
 * @package  Arcanedev\Sanitizer\Http
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
abstract class FormRequest extends BaseFormRequest
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Main Functions
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Sanitize input before validating.
19
     */
20 9
    public function validate()
21
    {
22 9
        $this->sanitize();
23
24 9
        parent::validate();
25
    }
26
27
    /**
28
     * Sanitize this request's input.
29
     */
30 9
    protected function sanitize()
31
    {
32 9
        $sanitized = sanitizer()->make(
33 9
            $this->all(),
34 9
            $this->sanitizerRules()
35 3
        );
36
37 9
        $this->replace($sanitized);
38 9
    }
39
40
    /**
41
     * Sanitizer's rules to be applied to the input.
42
     *
43
     * @return array
44
     */
45
    abstract protected function sanitizerRules();
46
}
47