/** * Return a list using path to find fields. * * @param string $path Path to look for info * @param string $default Default value if path not match * * @return array Found data */ private function getList($path, $default = array()) { // Strip off [] $path = preg_replace('/(^\\[)|(\\]$)/', '', $path); $selector = new Selector($this->data); return $selector->getAll($path, $default); }
/** * Find all information that match the path. * * @param string $contextPath Context to return * @param string $fieldPath Field to be matched * @param string $value Value to be matched * * @return array|null Array of contexts if found, null otherwise */ public function findAll($contextPath, $fieldPath, $value) { $contextObjects = $this->getAll($contextPath); $foundObjects = array_filter($contextObjects, function ($item) use($fieldPath, $value) { $contextParser = new Selector($item); $foundValues = $contextParser->getAll($fieldPath); return in_array($value, $foundValues); }); return $foundObjects; }