Completed
Pull Request — master (#1)
by De Cramer
02:40 queued 40s
created

ChainBuilderValidationException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 4
dl 0
loc 9
ccs 0
cts 8
cp 0
crap 6
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Oliverde8\Component\PhpEtl\Exception;
4
use Symfony\Component\Validator\ConstraintViolation;
5
use Throwable;
6
7
/**
8
 * Class ChainBuilderValidationException
9
 *
10
 * @author    de Cramer Oliver<[email protected]>
11
 * @copyright 2018 Oliverde8
12
 * @package Oliverde8\Component\PhpEtl\Exception
13
 */
14
class ChainBuilderValidationException extends \Exception
15
{
16
    /**
17
     * ChainBuilderValidationException constructor.
18
     *
19
     * @param $operation
20
     * @param ConstraintViolation[] $violations
21
     * @param int $code
22
     * @param Throwable|null $previous
23
     */
24
    public function __construct($operation, $violations, $code = 0, Throwable $previous = null)
25
    {
26
        $msg = "There was an error building the operation '$operation' : ";
27
        foreach ($violations as $violation) {
28
            $msg .= "\n - " . implode(', ', $violation->getParameters()) . " : " . $violation->getMessage();
29
        }
30
        $msg .= "\n";
31
32
        parent::__construct($msg, $code, $previous);
33
    }
34
}