ValidatorError   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * /src/Exception/models/ValidatorError.php
5
 *
6
 * @author TLe, Tarmo Leppänen <[email protected]>
7
 */
8
9
namespace App\Exception\models;
10
11
use Stringable;
12
use Symfony\Component\Validator\ConstraintViolationInterface;
13
use function str_replace;
14
15
/**
16
 * Class ValidatorError
17
 *
18
 * @package App\Exception\models
19
 * @author TLe, Tarmo Leppänen <[email protected]>
20
 */
21
class ValidatorError
22
{
23
    public string | Stringable $message;
24
    public string $propertyPath;
25
    public string $target;
26
    public string | null $code;
27
28 25
    public function __construct(ConstraintViolationInterface $error, string $target)
29
    {
30 25
        $this->message = $error->getMessage();
31 25
        $this->propertyPath = $error->getPropertyPath();
32 25
        $this->target = str_replace('\\', '.', $target);
33 25
        $this->code = $error->getCode();
34
    }
35
}
36