/** * Parse data by walking through keys * * @param $data * @param $keys * * @return array|mixed|null|string */ private function parseValueData($data, $keys) { $mainKey = $keys[0]; if (isset($mainKey) && !empty($data)) { if (Validate::json($data)) { $data = json_decode($data, true); } // unset first key since $data is already set to it unset($keys[0]); if (!empty($keys) && is_array($keys)) { foreach ($keys as $name) { $data = isset($data[$name]) && $data[$name] !== '' ? $data[$name] : null; } } } return $data; }
/** * Set Sub Group into bracket syntax * * @param $sub * * @return $this */ public function setSub($sub) { $this->sub = null; if (Validate::bracket($sub)) { $this->sub = $sub; } elseif (is_string($sub)) { $this->sub = "[{$sub}]"; } return $this; }