public function QueryPath::filterCallback in QueryPath 6
Same name and namespace in other branches
- 7.3 QueryPath/QueryPath.php \QueryPath::filterCallback()
- 7.2 QueryPath/QueryPath.php \QueryPath::filterCallback()
File
- QueryPath/
QueryPath.php, line 502
Class
Code
public function filterCallback($callback) {
$found = new SplObjectStorage();
$i = 0;
if (is_callable($callback)) {
foreach ($this->matches as $item) {
if (call_user_func($callback, $i++, $item) !== FALSE) {
$found
->attach($item);
}
}
}
else {
throw new QueryPathException('The specified callback is not callable.');
}
$this
->setMatches($found);
return $this;
}