* Extracts single values for each path, handling arrays and scalars. */
($json, array $paths)
| 260 | * Extracts single values for each path, handling arrays and scalars. |
| 261 | */ |
| 262 | private function extractSingleValues($json, array $paths): array { |
| 263 | $data = []; |
| 264 | foreach ($paths as $singlePath) { |
| 265 | $value = $this->get_nested_array_value($json, $singlePath); |
| 266 | $key = $this->getHeaderFromPath($singlePath); |
| 267 | if (is_array($value)) { |
| 268 | foreach ($value as $subKey => $subValue) { |
| 269 | $data[] = [$key, $subKey, $subValue]; |
| 270 | } |
| 271 | } else { |
| 272 | $data[] = ['', $key, $value]; |
| 273 | } |
| 274 | } |
| 275 | return $data; |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Gets the last segment of a path separated by '/'. |
no test coverage detected