| @@ 516-541 (lines=26) @@ | ||
| 513 | $node = $this->data; |
|
| 514 | ||
| 515 | // Traverse the registry to find the correct node for the result. |
|
| 516 | for ($i = 0, $n = count($nodes) - 1; $i < $n; $i++) |
|
| 517 | { |
|
| 518 | if (is_object($node)) |
|
| 519 | { |
|
| 520 | if (!isset($node->{$nodes[$i]}) && ($i != $n)) |
|
| 521 | { |
|
| 522 | $node->{$nodes[$i]} = new \stdClass; |
|
| 523 | } |
|
| 524 | ||
| 525 | // Pass the child as pointer in case it is an object |
|
| 526 | $node = &$node->{$nodes[$i]}; |
|
| 527 | ||
| 528 | continue; |
|
| 529 | } |
|
| 530 | ||
| 531 | if (is_array($node)) |
|
| 532 | { |
|
| 533 | if (!isset($node[$nodes[$i]]) && ($i != $n)) |
|
| 534 | { |
|
| 535 | $node[$nodes[$i]] = new \stdClass; |
|
| 536 | } |
|
| 537 | ||
| 538 | // Pass the child as pointer in case it is an array |
|
| 539 | $node = &$node[$nodes[$i]]; |
|
| 540 | } |
|
| 541 | } |
|
| 542 | ||
| 543 | // Get the old value if exists so we can return it |
|
| 544 | switch (true) |
|
| @@ 590-612 (lines=23) @@ | ||
| 587 | ||
| 588 | // Traverse the registry to find the correct node for the result. |
|
| 589 | // TODO Create a new private method from part of code below, as it is almost equal to 'set' method |
|
| 590 | for ($i = 0, $n = count($nodes) - 1; $i <= $n; $i++) |
|
| 591 | { |
|
| 592 | if (is_object($node)) |
|
| 593 | { |
|
| 594 | if (!isset($node->{$nodes[$i]}) && ($i != $n)) |
|
| 595 | { |
|
| 596 | $node->{$nodes[$i]} = new \stdClass; |
|
| 597 | } |
|
| 598 | ||
| 599 | // Pass the child as pointer in case it is an array |
|
| 600 | $node = &$node->{$nodes[$i]}; |
|
| 601 | } |
|
| 602 | elseif (is_array($node)) |
|
| 603 | { |
|
| 604 | if (!isset($node[$nodes[$i]]) && ($i != $n)) |
|
| 605 | { |
|
| 606 | $node[$nodes[$i]] = new \stdClass; |
|
| 607 | } |
|
| 608 | ||
| 609 | // Pass the child as pointer in case it is an array |
|
| 610 | $node = &$node[$nodes[$i]]; |
|
| 611 | } |
|
| 612 | } |
|
| 613 | ||
| 614 | if (!is_array($node)) |
|
| 615 | // Convert the node to array to make append possible |
|