1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of Dimtrovich/Validation. |
||
5 | * |
||
6 | * (c) 2023 Dimitri Sitchet Tomkeu <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view |
||
9 | * the LICENSE file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Dimtrovich\Validation\Rules; |
||
13 | |||
14 | class InArray extends AbstractRule |
||
15 | { |
||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $fillableParams = ['field']; |
||
20 | |||
21 | /** |
||
22 | * @var bool |
||
23 | */ |
||
24 | protected $strict = false; |
||
25 | |||
26 | /** |
||
27 | * Modifie le drapeau strict |
||
28 | */ |
||
29 | public function strict(bool $strict = true): self |
||
30 | { |
||
31 | $this->strict = $strict; |
||
32 | |||
33 | return $this; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritDoc} |
||
38 | */ |
||
39 | public function check($value): bool |
||
40 | { |
||
41 | 2 | $this->requireParameters($this->fillableParams); |
|
42 | |||
43 | 2 | $anotherValue = $this->validation->getValue($this->parameter('field')); |
|
0 ignored issues
–
show
|
|||
44 | 2 | $this->setAllowedValues((array) $anotherValue, 'or'); |
|
45 | |||
46 | if (! is_array($anotherValue)) { |
||
47 | 2 | return false; |
|
48 | } |
||
49 | |||
50 | 2 | return in_array($value, $anotherValue, $this->strict); |
|
51 | } |
||
52 | } |
||
53 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.