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