Test Failed
Pull Request — master (#222)
by Rustam
14:22 queued 33s
created

StaticRuleHandlerResolver::resolve()   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
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator;
6
7
use Yiisoft\Validator\Exception\RuleHandlerNotFoundException;
8
use Yiisoft\Validator\Rule\RuleHandlerInterface;
9
10
final class StaticRuleHandlerResolver implements RuleHandlerResolverInterface
11
{
12
    private array $validators;
13
14
    public function __construct(array $validators)
15
    {
16
        $this->validators = $validators;
17
    }
18
19
    public function resolve(string $className): RuleHandlerInterface
20
    {
21
        return $this->validators[$className] ?? throw new RuleHandlerNotFoundException($className);
22
    }
23
}
24