Example #1
0
 /**
  * Performs xpath limiter procedure
  * @param \SimpleXMLElement|array $input
  * @return mixed
  */
 function execute($input)
 {
     $xpath = $this->xpath;
     if ($input instanceof \SimpleXMLElement && isset($input->{$xpath})) {
         return $input->{$xpath};
     }
     if (is_object($input) && method_exists($input, 'xpath')) {
         $namespaces = $this->query->getNamespaces();
         foreach ($namespaces as $prefix => $ns) {
             $input->registerXPathNamespace($prefix, $ns);
         }
         return $input->xpath($xpath);
     } elseif (qtil\ArrayUtil::isIterable($input)) {
         $results = [];
         foreach ($input as $i) {
             if (is_object($i) && method_exists($i, 'xpath')) {
                 $results[] = $this->execute($i);
             }
         }
         return $results;
     }
 }