Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
8 / 8 |
|
85.71% |
6 / 7 |
|
60.00% |
3 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| TypeMetadata | |
100.00% |
8 / 8 |
|
85.71% |
6 / 7 |
|
60.00% |
3 / 5 |
|
100.00% |
2 / 2 |
3.58 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| describe | |
100.00% |
7 / 7 |
|
83.33% |
5 / 6 |
|
50.00% |
2 / 4 |
|
100.00% |
1 / 1 |
2.50 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Quma\Hydration; |
| 6 | |
| 7 | /** @internal */ |
| 8 | final readonly class TypeMetadata |
| 9 | { |
| 10 | /** |
| 11 | * @param 'named'|'union' $kind |
| 12 | * @param non-empty-list<NamedTypeMetadata> $names |
| 13 | */ |
| 14 | public function __construct( |
| 15 | public string $kind, |
| 16 | public bool $allowsNull, |
| 17 | public array $names, |
| 18 | ) {} |
| 19 | |
| 20 | public function describe(): string |
| 21 | { |
| 22 | $names = array_map( |
| 23 | static fn(NamedTypeMetadata $name): string => $name->describe(), |
| 24 | $this->names, |
| 25 | ); |
| 26 | |
| 27 | if ($this->allowsNull) { |
| 28 | $names[] = 'null'; |
| 29 | } |
| 30 | |
| 31 | return implode('|', $names); |
| 32 | } |
| 33 | } |