BaseRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareForValidation() 0 8 1
A beforeValidation() 0 3 1
A validationData() 0 4 1
A transform() 0 4 1
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