Passed
Pull Request — master (#247)
by Michael
02:00
created

TooManyDefaultProperties::new()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 14
ccs 12
cts 12
cp 1
rs 9.8666
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\Exception;
6
7
use Doctrine\Annotations\Metadata\PropertyMetadata;
8
use LogicException;
9
use function array_map;
10
use function count;
11
use function implode;
12
use function sprintf;
13
14
final class TooManyDefaultProperties extends LogicException
15
{
16 1
    public static function new(string $name, PropertyMetadata ...$properties) : self
17
    {
18 1
        return new self(
19 1
            sprintf(
20 1
                'The annotation "%s" can only have at most one default property, currently has %d: "%s".',
21 1
                $name,
22 1
                count($properties),
23 1
                implode(
24 1
                    '", "',
25 1
                    array_map(
26
                        static function (PropertyMetadata $property) : string {
27 1
                            return $property->getName();
28 1
                        },
29 1
                        $properties
30
                    )
31
                )
32
            )
33
        );
34
    }
35
}
36