| @@ 43-53 (lines=11) @@ | ||
| 40 | * |
|
| 41 | * @param array|object $target |
|
| 42 | */ |
|
| 43 | protected function applyNodeResults(&$target) |
|
| 44 | { |
|
| 45 | if ($target instanceof self) { |
|
| 46 | $target = $target->getResult(); |
|
| 47 | $this->applyNodeResults($target); |
|
| 48 | } elseif (is_array($target) || is_object($target)) { |
|
| 49 | foreach ($target as &$value) { |
|
| 50 | $this->applyNodeResults($value); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Get the processed result |
|
| @@ 122-135 (lines=14) @@ | ||
| 119 | * @param mixed $value |
|
| 120 | * @return mixed |
|
| 121 | */ |
|
| 122 | protected function resolve($value) |
|
| 123 | { |
|
| 124 | while ($value instanceof self) { |
|
| 125 | $value = $value->getResult(); |
|
| 126 | } |
|
| 127 | ||
| 128 | if (is_array($value) || is_object($value)) { |
|
| 129 | foreach ($value as &$item) { |
|
| 130 | $item = $this->resolve($item); |
|
| 131 | } |
|
| 132 | } |
|
| 133 | ||
| 134 | return $value; |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * Apply processing to this node |
|
| @@ 160-169 (lines=10) @@ | ||
| 157 | * |
|
| 158 | * @param array|object $target |
|
| 159 | */ |
|
| 160 | protected function applyNodeResults(&$target) |
|
| 161 | { |
|
| 162 | foreach ($target as &$value) { |
|
| 163 | if ($value instanceof Node) { |
|
| 164 | $value = $value->getResult(); |
|
| 165 | } elseif (is_array($value) || is_object($value)) { |
|
| 166 | $this->applyNodeResults($value); |
|
| 167 | } |
|
| 168 | } |
|
| 169 | } |
|
| 170 | } |
|
| 171 | ||