FormRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sanitize() 0 9 1
sanitizerRules() 0 1 ?
A validate() 0 6 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