Passed
Push — master ( e05223...e18482 )
by
unknown
06:52 queued 03:38
created

RuleWithBuiltInHandler::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
eloc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Rule;
6
7
use Yiisoft\Validator\Result;
8
use Yiisoft\Validator\RuleHandlerInterface;
9
use Yiisoft\Validator\RuleInterface;
10
use Yiisoft\Validator\ValidationContext;
11
12
final class RuleWithBuiltInHandler implements RuleInterface, RuleHandlerInterface
13
{
14
    public function validate(mixed $value, object $rule, ValidationContext $context): Result
15
    {
16
        $result = new Result();
17
18
        if ($value !== 42) {
19
            $result->addError('Value must be 42.');
20
        }
21
22
        return $result;
23
    }
24
25
    public function getHandler(): string|RuleHandlerInterface
26
    {
27
        return $this;
28
    }
29
}
30