lib/Node: Remove method `findNodeBy()'

The new `DocTree' class provides `getNode()'.
This commit is contained in:
Eric Lippmann 2014-07-28 19:07:13 +02:00
parent 51bc0274f3
commit e26d360561
1 changed files with 0 additions and 30 deletions

View File

@ -4,9 +4,6 @@
namespace Icinga\Data\Tree; namespace Icinga\Data\Tree;
use Exception;
use RecursiveIteratorIterator;
use RuntimeException;
use SplDoublyLinkedList; use SplDoublyLinkedList;
class Node extends SplDoublyLinkedList implements NodeInterface class Node extends SplDoublyLinkedList implements NodeInterface
@ -79,31 +76,4 @@ class Node extends SplDoublyLinkedList implements NodeInterface
} }
return $current; return $current;
} }
/**
* Find the first child node by searching through nodes deeper than the immediate children using a custom function
*
* @param $callback
*
* @return NodeInterface|null
* @throws Exception
*/
public function findNodeBy($callback)
{
if (! is_callable($callback)) {
throw new RuntimeException('Callable expected');
}
foreach (new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST) as $node) {
try {
$found = call_user_func($callback, $node);
} catch (Exception $e) {
// TODO(el): Log exception and return false instead?
throw $e;
}
if ($found) {
return $node;
}
}
return null;
}
} }