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

TooManyDefaultProperties   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 12
dl 0
loc 16
ccs 12
cts 12
cp 1
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 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