You are here

public function QueryPath::deepest in QueryPath 6

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

File

QueryPath/QueryPath.php, line 845

Class

QueryPath

Code

public function deepest() {
  $deepest = 0;
  $winner = new SplObjectStorage();
  foreach ($this->matches as $m) {
    $local_deepest = 0;
    $local_ele = $this
      ->deepestNode($m, 0, NULL, $local_deepest);
    if ($local_deepest > $deepest) {
      $winner = new SplObjectStorage();
      foreach ($local_ele as $lele) {
        $winner
          ->attach($lele);
      }
      $deepest = $local_deepest;
    }
    elseif ($local_deepest == $deepest) {
      foreach ($local_ele as $lele) {
        $winner
          ->attach($lele);
      }
    }
  }
  $this
    ->setMatches($winner);
  return $this;
}