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