| Conditions | 7 |
| Paths | 8 |
| Total Lines | 21 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 7 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | 21 | public static function apply(&$original, $patch) |
|
| 9 | { |
||
| 10 | 21 | if (null === $patch) { |
|
| 11 | 1 | $original = null; |
|
| 12 | 20 | } elseif (is_object($patch)) { |
|
| 13 | 15 | foreach (get_object_vars($patch) as $key => $val) { |
|
| 14 | 14 | if ($val === null) { |
|
| 15 | 7 | unset($original->$key); |
|
| 16 | } else { |
||
| 17 | 12 | if (!is_object($original)) { |
|
| 18 | 2 | $original = new \stdClass(); |
|
| 19 | } |
||
| 20 | 12 | $branch = &$original->$key; |
|
| 21 | 12 | if (null === $branch) { |
|
| 22 | 6 | $branch = new \stdClass(); |
|
| 23 | } |
||
| 24 | 12 | self::apply($branch, $val); |
|
| 25 | } |
||
| 26 | } |
||
| 27 | } else { |
||
| 28 | 15 | $original = $patch; |
|
| 29 | } |
||
| 31 | } |