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

ValidatorInterfaceProxy::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 11
ccs 0
cts 4
cp 0
crap 2
rs 10
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