Issues (88)

src/Rules/MissingWith.php (1 issue)

Labels
Severity
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
use BlitzPHP\Utilities\Iterable\Arr;
15
use BlitzPHP\Utilities\Support\Invader;
16
use Rakit\Validation\Rule as RakitRule;
17
18
class MissingWith extends Missing
19
{
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function fillParameters(array $params): RakitRule
24
    {
25
        $this->params['fields'] = $params;
26
27
        return $this;
28
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33
    public function check($value): bool
34
    {
35
        $this->requireParameters(['fields']);
36
37
        $fields = $this->parameter('fields');
38
        $inputs = Invader::make($this->validation)->inputs;
0 ignored issues
show
It seems like $this->validation can also be of type null; however, parameter $obj of BlitzPHP\Utilities\Support\Invader::make() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
        $inputs = Invader::make(/** @scrutinizer ignore-type */ $this->validation)->inputs;
Loading history...
39
40
        if (Arr::hasAny($inputs, $fields)) {
41
            return parent::check($value);
42
        }
43
44
        return true;
45
    }
46
}
47