Completed
Push — master ( 0edf62...6ee369 )
by Iman
09:40 queued 01:18
created

Validator::__destruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan\Reactions;
4
5
use Imanghafoori\HeyMan\Chain;
6
7
class Validator
8
{
9
    /**
10
     * @var Chain
11
     */
12
    private $chain;
13
14
    private $validationData;
15
16
    /**
17
     * YouShouldHave constructor.
18
     *
19
     * @param Chain $chain
20
     * @param $validationData
21
     */
22
    public function __construct(Chain $chain, $validationData)
23
    {
24
        $this->chain = $chain;
25
        $this->validationData = $validationData;
26
    }
27
28
    public function beforeValidationModifyData($callable)
29
    {
30
        $this->validationData[0] = app()->call($callable, [$this->validationData[0]]);
31
    }
32
33
    public function __destruct()
34
    {
35
        $data = $this->validationData;
36
        $this->chain->predicate = app(ResponderFactory::class)->validatorCallback(...$data);
0 ignored issues
show
Bug introduced by
The call to Imanghafoori\HeyMan\Reac...ry::validatorCallback() has too few arguments starting with rules. ( Ignorable by Annotation )

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

36
        $this->chain->predicate = app(ResponderFactory::class)->/** @scrutinizer ignore-call */ validatorCallback(...$data);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
37
        app(Chain::class)->submitChainConfig();
38
    }
39
}