* Extracts single values for each path, handling arrays and scalars. */
($json, array $paths)
| 225 | * Extracts single values for each path, handling arrays and scalars. |
| 226 | */ |
| 227 | private function extractSingleValues($json, array $paths): array { |
| 228 | $data = []; |
| 229 | foreach ($paths as $singlePath) { |
| 230 | $value = $this->get_nested_array_value($json, $singlePath); |
| 231 | $key = $this->getHeaderFromPath($singlePath); |
| 232 | if (is_array($value)) { |
| 233 | foreach ($value as $subKey => $subValue) { |
| 234 | $data[] = [$key, $subKey, $subValue]; |
| 235 | } |
| 236 | } else { |
| 237 | $data[] = ['', $key, $value]; |
| 238 | } |
| 239 | } |
| 240 | return $data; |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Gets the last segment of a path separated by '/'. |
no test coverage detected