BaseRequest::beforeValidation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PerfectOblivion\Valid;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use PerfectOblivion\Valid\Traits\SanitizesInput;
7
use PerfectOblivion\Valid\Traits\PreparesCustomRulesForFormRequest;
8
9
class BaseRequest extends FormRequest
10
{
11
    use SanitizesInput, PreparesCustomRulesForFormRequest;
12
13
    /**
14
     * Prepare the data for validation.
15
     */
16
    protected function prepareForValidation()
17
    {
18
        $this->sanitizeData();
19
20
        $this->beforeValidation();
21
22
        return $this->validationData();
23
    }
24
25
    /**
26
     * Run any logic needed prior to validation running.
27
     */
28
    protected function beforeValidation()
29
    {
30
    }
31
32
    /**
33
     * Get data to be validated from the request.
34
     *
35
     * @return array
36
     */
37
    protected function validationData()
38
    {
39
        return $this->all();
40
    }
41
42
    /**
43
     * Transform the request data if necessary.
44
     *
45
     * @param  array  $data
46
     *
47
     * @return array
48
     */
49
    protected function transform($data)
50
    {
51
        return $data;
52
    }
53
}
54