Passed
Push — feature/initial-implementation ( fae671...591f29 )
by Fike
02:37
created

Violations   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 22
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A remap() 0 20 2
1
<?php
2
3
namespace AmaTeam\ElasticSearch\Utility;
4
5
use Symfony\Component\Validator\ConstraintViolation;
6
use Symfony\Component\Validator\ConstraintViolationInterface;
7
8
class Violations
9
{
10
    public static function remap(ConstraintViolationInterface $violation, $root, string $path): ConstraintViolation
11
    {
12
        $propertyPath = $path . '.' . $violation->getPropertyPath();
13
        $cause = null;
14
        $constraint = null;
15
        if ($violation instanceof ConstraintViolation) {
16
            $cause = $violation->getCause();
17
            $constraint = $violation->getConstraint();
18
        }
19
        return new ConstraintViolation(
20
            $violation->getMessage(),
21
            $violation->getMessageTemplate(),
22
            $violation->getParameters(),
23
            $root,
24
            $propertyPath,
25
            $violation->getInvalidValue(),
26
            $violation->getPlural(),
27
            $violation->getCode(),
28
            $constraint,
29
            $cause
30
        );
31
    }
32
}
33