Passed
Push — master ( 13d022...2fdb27 )
by Dmitry
04:41
created

ValidationResult::getErrors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace SymfonyBundles\ServiceLayer\Result;
4
5
use Symfony\Component\Validator\ConstraintViolationInterface;
6
use Symfony\Component\Validator\ConstraintViolationListInterface;
7
8
/**
9
 * Class for receiving validation errors.
10
 */
11
final class ValidationResult implements ValidationResultInterface
12
{
13
    /**
14
     * @var array
15
     */
16
    private array $errors = [];
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_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
17
18
    /**
19
     * @param ConstraintViolationListInterface $constraintViolationList
20
     */
21 4
    public function __construct(ConstraintViolationListInterface $constraintViolationList)
22
    {
23
        /** @var ConstraintViolationInterface $violation */
24 4
        foreach ($constraintViolationList as $violation) {
25 4
            $this->errors[$violation->getPropertyPath()] = [
26 4
                'message' => $violation->getMessageTemplate(),
27 4
                'parameters' => $violation->getParameters(),
28
            ];
29
        }
30 4
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 4
    public function getErrors(): array
36
    {
37 4
        return $this->errors;
38
    }
39
}
40