You are here

public function QueryPath::last in QueryPath 6

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

File

QueryPath/QueryPath.php, line 1712

Class

QueryPath

Code

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