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

InvalidValue::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\Metadata\Constraint;
6
7
use function gettype;
8
use function implode;
9
use function sprintf;
10
11
final class InvalidValue extends ConstraintNotFulfilled
12
{
13
    /**
14
     * @param mixed[] $allowedValues
15
     * @param mixed   $value
16
     */
17 1
    public static function new(array $allowedValues, $value) : self
18
    {
19
        // TODO: Describe values
20 1
        return new self(
21 1
            sprintf(
22 1
                'Invalid value "%s" for allowed values: "%s".',
23 1
                gettype($value),
24 1
                implode(',', $allowedValues)
25
            )
26
        );
27
    }
28
}
29