InvalidPropertyException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 12
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Exception\Validation;
6
7
use LAG\AdminBundle\Exception\Exception;
8
use Symfony\Component\Validator\ConstraintViolationInterface;
9
use Symfony\Component\Validator\ConstraintViolationListInterface;
10
11
class InvalidPropertyException extends Exception
12
{
13
    public function __construct(?string $propertyName, ConstraintViolationListInterface $errors)
14
    {
15
        $message = sprintf('The property "%s" is not valid :', $propertyName);
16
17
        /** @var ConstraintViolationInterface $error */
18
        foreach ($errors as $error) {
19
            $message .= \PHP_EOL.$error->getPropertyPath().': '.$error->getMessage();
20
        }
21
22
        parent::__construct($message);
23
    }
24
}
25