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

InvalidAnnotationValue::new()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
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\AnnotationMetadata;
9
use Exception;
10
use Throwable;
11
use function sprintf;
12
13
final class InvalidAnnotationValue extends Exception implements ValidationException
14
{
15
    private function __construct(string $message, ?Throwable $previous = null)
16
    {
17
        parent::__construct($message, 0, $previous);
18
    }
19
20
    public static function new(AnnotationMetadata $annotationMetadata, Throwable $previous) : self
21
    {
22
        return new self(
23
            sprintf(
24
                'Invalid value for annotation %s',
25
                $annotationMetadata->getName()
26
            ),
27
            $previous
28
        );
29
    }
30
}
31