Passed
Pull Request — master (#415)
by
unknown
29:22 queued 26:39
created

ObjectWithCallbackMethod::validateName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Support\Data\ObjectWithCallbackMethod;
6
7
use Yiisoft\Validator\Result;
8
use Yiisoft\Validator\Rule\Callback;
9
use Yiisoft\Validator\ValidationContext;
10
11
final class ObjectWithCallbackMethod
12
{
13
    #[Callback(method: 'validateName')]
14
    private string $name;
0 ignored issues
show
introduced by
The private property $name is not used, and could be removed.
Loading history...
15
16
    public static function validateName(mixed $value, object $rule, ValidationContext $context): Result
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

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

16
    public static function validateName(mixed $value, object $rule, /** @scrutinizer ignore-unused */ ValidationContext $context): Result

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $rule is not used and could be removed. ( Ignorable by Annotation )

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

16
    public static function validateName(mixed $value, /** @scrutinizer ignore-unused */ object $rule, ValidationContext $context): Result

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        $result = new Result();
19
        if ($value !== 'foo') {
20
            $result->addError('Value must be "foo"!');
21
        }
22
23
        return $result;
24
    }
25
}
26