FormRequest::sanitize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
ccs 7
cts 7
cp 1
crap 1
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