1 | <?php |
||
21 | class Validator |
||
22 | { |
||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $likes = []; |
||
27 | |||
28 | /** |
||
29 | * Validator constructor. |
||
30 | */ |
||
31 | public function __construct() |
||
35 | |||
36 | /** |
||
37 | * @param Message $message |
||
38 | * @return Status[]|Collection |
||
39 | */ |
||
40 | public function validate(Message $message) |
||
41 | { |
||
42 | $response = new Collection(); |
||
43 | |||
44 | // If has no mentions |
||
45 | if (!count($message->mentions)) { |
||
46 | if ($this->validateText($message)) { |
||
47 | $response->push(new Status($message->user, Status::STATUS_NO_USER)); |
||
48 | } |
||
49 | |||
50 | return $response; |
||
51 | } |
||
52 | |||
53 | foreach ($message->mentions as $mention) { |
||
54 | // Ignore bot queries |
||
55 | if ($message->user->isBot()) { |
||
56 | continue; |
||
57 | } |
||
58 | |||
59 | $response->push($this->validateMessage($message, $mention)); |
||
60 | } |
||
61 | |||
62 | return $response; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param Message $message |
||
67 | * @param User $mention |
||
68 | * @return Status |
||
69 | */ |
||
70 | protected function validateMessage(Message $message, User $mention) |
||
86 | |||
87 | /** |
||
88 | * @param Message $message |
||
89 | * @param User $mention |
||
90 | * @return bool |
||
91 | */ |
||
92 | protected function validateUser(Message $message, User $mention) |
||
96 | |||
97 | /** |
||
98 | * @param Message $message |
||
99 | * @param User $mention |
||
100 | * @return bool |
||
101 | */ |
||
102 | protected function validateTimeout(Message $message, User $mention) |
||
109 | |||
110 | |||
111 | /** |
||
112 | * @param Message $message |
||
113 | * @return bool |
||
114 | */ |
||
115 | protected function validateText(Message $message) |
||
121 | } |
||
122 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..