Passed
Pull Request — master (#132)
by Dmitriy
12:39 queued 10s
created

ValidatorInterfaceProxy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validate() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Proxy;
6
7
use Yiisoft\Validator\Result;
8
use Yiisoft\Validator\ValidatorInterface;
9
use Yiisoft\Yii\Debug\Collector\ValidatorCollectorInterface;
10
11
final class ValidatorInterfaceProxy implements ValidatorInterface
12
{
13
    public function __construct(
14
        private ValidatorInterface $validator,
15
        private ValidatorCollectorInterface $collector,
16
    ) {
17
    }
18
19
    public function validate(mixed $data, iterable $rules = []): Result
20
    {
21
        $result = $this->validator->validate($data, $rules);
22
23
        $this->collector->collect(
24
            $data,
25
            $rules,
26
            $result,
27
        );
28
29
        return $result;
30
    }
31
}
32