public static function getValue($key, $container) { if ($key === '') { return $container; } $keyNibbles = explode('.', $key); $keyNibble = array_shift($keyNibbles); if ($container) { // Traverse arrays if (is_numeric($keyNibble) && isset($container[$keyNibble])) { return JsonPath::getValue(implode('.', $keyNibbles), $container[$keyNibble]); } if (isset($container->{$keyNibble})) { return JsonPath::getValue(implode('.', $keyNibbles), $container->{$keyNibble}); } } return null; }
protected function getValue() { //traverse path in $this->generator->data; return JsonPath::getValue(implode('.', $this->path), $this->generator->data); }