Conditions | 8 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 8 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | 27 | public function merge(?array ...$parts): ?array |
|
12 | { |
||
13 | 27 | $schema = null; |
|
14 | 27 | foreach ($parts as $part) { |
|
15 | 21 | if (empty($part)) { |
|
16 | 6 | $schema ??= $part; |
|
17 | 6 | continue; |
|
18 | } |
||
19 | 17 | foreach ($part as $role => $body) { |
|
20 | 17 | if (!is_string($role)) { |
|
21 | 1 | $schema[] = $body; |
|
22 | 1 | continue; |
|
23 | } |
||
24 | 16 | if ($schema !== null && array_key_exists($role, $schema)) { |
|
|
|||
25 | 5 | if ($schema[$role] === $body) { |
|
26 | 2 | continue; |
|
27 | } |
||
28 | 3 | throw new DuplicateRoleException($role); |
|
29 | } |
||
30 | 16 | $schema[$role] = $body; |
|
31 | } |
||
32 | } |
||
33 | |||
34 | 24 | return $schema; |
|
35 | } |
||
37 |