Completed
Push — master ( d27e1e...d6d70b )
by Hannes
01:43
created

AbstractValidator::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace hanneskod\clean;
6
7
/**
8
 * Extension point for custom validators
9
 */
10
abstract class AbstractValidator implements ValidatorInterface
11
{
12
    private ValidatorInterface $validator;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
13
14
    public function __construct()
15
    {
16
        $this->validator = $this->create();
17
    }
18
19
    abstract protected function create(): ValidatorInterface;
20
21
    public function applyTo($data): ResultInterface
22
    {
23
        return $this->validator->applyTo($data);
24
    }
25
26
    public function validate($data)
27
    {
28
        return $this->applyTo($data)->getValidData();
29
    }
30
}
31