Completed
Pull Request — master (#24)
by ARCANEDEV
07:54
created

FormRequest::validateResolved()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
crap 2
1
<?php namespace Arcanedev\Support\Http;
2
3
use Illuminate\Foundation\Http\FormRequest as BaseFormRequest;
4
5
/**
6
 * Class     FormRequest
7
 *
8
 * @package  Arcanedev\Support
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
abstract class FormRequest extends BaseFormRequest
12
{
13
    /* -----------------------------------------------------------------
14
     |  Main Methods
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Determine if the user is authorized to make this request.
20
     *
21
     * @return bool
22
     */
23 6
    public function authorize()
24
    {
25 6
        return true;
26
    }
27
28
    /**
29
     * Get the validation rules that apply to the request.
30
     *
31
     * @return array
32
     */
33
    abstract public function rules();
34
35
    /**
36
     * Validate the class instance.
37
     *
38
     * @return void
39
     */
40 6
    public function validateResolved()
41
    {
42 6
        parent::validateResolved();
43
44 6
        if (method_exists($this, 'prepareAfterValidation'))
45 6
            $this->prepareAfterValidation();
0 ignored issues
show
Documentation Bug introduced by
The method prepareAfterValidation does not exist on object<Arcanedev\Support\Http\FormRequest>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
46 6
    }
47
}
48