1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
7: *
8: * For the full copyright and license information, please view
9: * the file license.txt that was distributed with this source code.
10: * @package Nette\Iterators
11: */
12:
13:
14:
15: /**
16: * Callback iterator filter.
17: *
18: * @author David Grudl
19: * @package Nette\Iterators
20: */
21: class NNCallbackFilterIterator extends FilterIterator
22: {
23: /** @var callable */
24: private $callback;
25:
26:
27: /**
28: * Constructs a filter around another iterator.
29: * @param
30: * @param callable
31: */
32: public function __construct(Iterator $iterator, $callback)
33: {
34: parent::__construct($iterator);
35: $this->callback = callback($callback);
36: }
37:
38:
39:
40: public function accept()
41: {
42: return $this->callback->invoke($this);
43: }
44:
45: }
46: