GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Validator::setMessages()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Milkmeowo\Framework\Base\Validators;
4
5
use Prettus\Validator\AbstractValidator;
6
7
class Validator extends AbstractValidator
8
{
9
    /**
10
     * Validation Custom Messages.
11
     *
12
     * @var array
13
     */
14
    protected $messages = [];
15
16
    /**
17
     * Validation Custom Attributes.
18
     *
19
     * @var array
20
     */
21
    protected $attributes = [];
22
23
    /**
24
     * Get Custom error messages for validation.
25
     *
26
     * @return array
27
     */
28
    public function getMessages()
29
    {
30
        return $this->messages;
31
    }
32
33
    /**
34
     * Set Custom error messages for Validation.
35
     * @param array $messages
36
     *
37
     * @return $this
38
     */
39
    public function setMessages(array $messages)
40
    {
41
        $this->messages = $messages;
42
43
        return $this;
44
    }
45
46
    /**
47
     * Get Custom error attributes for validation.
48
     *
49
     * @return array
50
     */
51
    public function getAttributes()
52
    {
53
        return $this->attributes;
54
    }
55
56
    /**
57
     * Set Custom error attributes for Validation.
58
     *
59
     * @param array $attributes
60
     *
61
     * @return $this
62
     */
63
    public function setAttributes(array $attributes)
64
    {
65
        $this->attributes = $attributes;
66
67
        return $this;
68
    }
69
70
    /**
71
     * Pass the data and the rules to the validator.
72
     *
73
     * @param string $action
74
     * @return bool
75
     */
76
    public function passes($action = null)
77
    {
78
        $rules = $this->getRules($action);
0 ignored issues
show
Bug introduced by
It seems like $action defined by parameter $action on line 76 can also be of type string; however, Prettus\Validator\AbstractValidator::getRules() does only seem to accept null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
79
        $messages = $this->getMessages();
80
        $attributes = $this->getAttributes();
81
        $validator = app('validator')->make($this->data, $rules, $messages, $attributes);
82
        if ($validator->fails()) {
83
            $this->errors = $validator->messages();
84
85
            return false;
86
        }
87
88
        return true;
89
    }
90
}
91