Conditions | 3 |
Paths | 3 |
Total Lines | 32 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 1 | public function __construct(?array $properties) |
|
18 | { |
||
19 | 1 | if (null === $properties) { |
|
|
|||
20 | 1 | parent::__construct(static::NAME, null); |
|
21 | |||
22 | 1 | return; |
|
23 | } |
||
24 | |||
25 | 1 | Assert::isNonEmptyList($properties); |
|
26 | 1 | Assert::allIsInstanceOf($properties, PropertyInterface::class); |
|
27 | |||
28 | 1 | $required = array_values( |
|
29 | 1 | array_map( |
|
30 | 1 | function (PropertyInterface $property): string { |
|
31 | 1 | return $property->getName(); |
|
32 | 1 | }, |
|
33 | 1 | array_filter( |
|
34 | $properties, |
||
35 | 1 | function (PropertyInterface $property): bool { |
|
36 | 1 | return $property->isRequired(); |
|
37 | 1 | } |
|
38 | ) |
||
39 | ) |
||
40 | ); |
||
41 | |||
42 | 1 | if (0 === \count($required)) { |
|
43 | 1 | parent::__construct(static::NAME, null); |
|
44 | |||
45 | 1 | return; |
|
46 | } |
||
47 | |||
48 | 1 | parent::__construct(static::NAME, $required); |
|
49 | 1 | } |
|
51 |