Passed
Pull Request — new-parser-ast-metadata (#3)
by
unknown
03:27
created

InvalidType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A new() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Metadata\Constraint;
6
7
use function gettype;
8
use function is_scalar;
9
use function sprintf;
10
11
final class InvalidType extends ConstraintNotFulfilled
12
{
13
    /**
14
     * @param mixed $value
15
     */
16 3
    public static function new(string $typeDescription, $value) : self
17
    {
18
        // TODO: Describe value
19 3
        return new self(
20 3
            sprintf(
21 3
                'Invalid value "%s" fo type %s.',
22 3
                ! is_scalar($value) ? gettype($value) : $value,
23 3
                $typeDescription
24
            )
25
        );
26
    }
27
}
28