| Conditions | 6 |
| Paths | 6 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6.4689 |
| Changes | 0 | ||
| 1 | <?php |
||
| 52 | 8 | public static function setByPath(&$subject, array $path, $value) |
|
| 53 | { |
||
| 54 | 8 | $ptr = & $subject; |
|
| 55 | 8 | foreach ($path as $key) { |
|
| 56 | 8 | if (is_object($ptr)) { |
|
| 57 | if (!isset($ptr->$key)) { |
||
| 58 | $ptr->$key = array(); |
||
| 59 | } |
||
| 60 | $ptr = & $ptr->$key; |
||
| 61 | 8 | } elseif (is_array($ptr)) { |
|
| 62 | 8 | if (!isset($ptr[$key])) { |
|
| 63 | 8 | $ptr[$key] = array(); |
|
| 64 | 8 | } |
|
| 65 | 8 | $ptr = & $ptr[$key]; |
|
| 66 | 8 | } |
|
| 67 | 8 | } |
|
| 68 | 8 | $ptr = $value; |
|
| 69 | 8 | return $subject; |
|
| 70 | } |
||
| 71 | } |