1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004, 2011 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
11: */
12:
13:
14:
15: /**
16: * Callback iterator filter.
17: *
18: * @author David Grudl
19: */
20: class CallbackFilterIterator extends FilterIterator
21: {
22: /** @var callback */
23: private $callback;
24:
25:
26: /**
27: * Constructs a filter around another iterator.
28: * @param
29: * @param callback
30: */
31: function __construct(Iterator $iterator, $callback)
32: {
33: parent::__construct($iterator);
34: $this->callback = $callback;
35: }
36:
37:
38:
39: function accept()
40: {
41: return call_user_func($this->callback, $this);
42: }
43:
44: }
45: