You are here

public function QueryPath::first in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/QueryPath.php \QueryPath::first()
  2. 7.2 QueryPath/QueryPath.php \QueryPath::first()

File

QueryPath/QueryPath.php, line 1678

Class

QueryPath

Code

public function first() {
  $found = new SplObjectStorage();
  foreach ($this->matches as $m) {
    if ($m->nodeType == XML_ELEMENT_NODE) {
      $found
        ->attach($m);
      break;
    }
  }
  $this
    ->setMatches($found);
  $this->matches = $found;
  return $this;
}