Failed Conditions
Pull Request — new-parser-ast-metadata (#3)
by
unknown
02:22
created

InvalidPropertyValue::new()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Assembler\Validator\Exception;
6
7
use Doctrine\Annotations\Exception\ValidationException;
8
use Doctrine\Annotations\Metadata\PropertyMetadata;
9
use Exception;
10
use Throwable;
11
use function sprintf;
12
13
final class InvalidPropertyValue extends Exception implements ValidationException
14
{
15 1
    private function __construct(string $message, ?Throwable $previous = null)
16
    {
17 1
        parent::__construct($message, 0, $previous);
18 1
    }
19
20 1
    public static function new(PropertyMetadata $propertyMetadata, Throwable $previous) : self
21
    {
22 1
        return new self(
23 1
            sprintf(
24 1
                'Invalid value for property %s',
25 1
                $propertyMetadata->getName()
26
            ),
27 1
            $previous
28
        );
29
    }
30
}
31