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

AbstractValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 45
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