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

CompositeTypeDescriber::describe()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
ccs 9
cts 9
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\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