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

InvalidType::new()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

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 2
nc 1
nop 2
crap 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