CompositeHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
ccs 0
cts 0
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Rule;
6
7
use Yiisoft\Validator\Exception\UnexpectedRuleException;
8
use Yiisoft\Validator\Result;
9
use Yiisoft\Validator\RuleHandlerInterface;
10
use Yiisoft\Validator\ValidationContext;
11
12
/**
13
 * A handler for {@see Composite} handler. Validates group of rules.
14
 */
15
final class CompositeHandler implements RuleHandlerInterface
16
{
17
    public function validate(mixed $value, object $rule, ValidationContext $context): Result
18
    {
19
        if (!$rule instanceof Composite) {
20
            throw new UnexpectedRuleException(Composite::class, $rule);
21
        }
22
23
        return $context->validate($value, $rule->getRules());
24
    }
25
}
26