Failed Conditions
Push — master ( ecccd5...ae55c7 )
by Marco
33s
created

CompositeTypeDescriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 22
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A describe() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Type;
6
7
use function array_map;
8
use function implode;
9
use function sprintf;
10
11
/**
12
 * @internal
13
 */
14
final class CompositeTypeDescriber
15
{
16
    private function __construct()
17
    {
18
    }
19
20
    /**
21
     * @param Type[] $subTypes
22
     */
23 10
    public static function describe(string $separator, $subTypes) : string
24
    {
25 10
        return implode(
26 10
            $separator,
27 10
            array_map(
28
                static function (Type $subType) : string {
29 10
                    if ($subType instanceof CompositeType) {
30 3
                        return sprintf('(%s)', $subType->describe());
31
                    }
32
33 10
                    return $subType->describe();
34 10
                },
35 10
                $subTypes
36
            )
37
        );
38
    }
39
}
40