Failed Conditions
Push — type ( c389f1...fc7bda )
by Michael
02:26
created

TooManyDefaultProperties   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 12
dl 0
loc 16
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A new() 0 14 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
    public static function new(string $name, PropertyMetadata ...$properties) : self
17
    {
18
        return new self(
19
            sprintf(
20
                'The annotation "%s" can only have at most one default property, currently has %d: "%s".',
21
                $name,
22
                count($properties),
23
                implode(
24
                    '", "',
25
                    array_map(
26
                        static function (PropertyMetadata $property) : string {
27
                            return $property->getName();
28
                        },
29
                        $properties
30
                    )
31
                )
32
            )
33
        );
34
    }
35
}
36