1 | <?php |
||
33 | class FilteredIterator extends FilterIterator |
||
34 | { |
||
35 | /** |
||
36 | * A list of callback functions. |
||
37 | * |
||
38 | * @var array of Callable objects/functions |
||
39 | */ |
||
40 | protected $filters = []; |
||
41 | |||
42 | /** |
||
43 | * FilteredIterator Constructor. |
||
44 | * |
||
45 | * Initializes the iterator using the CSV reader and its array of callback |
||
46 | * filter functions/callables. |
||
47 | * |
||
48 | * @param \CSVelte\Reader $reader The CSV reader being iterated |
||
49 | * @param array $filters The list of callbacks |
||
50 | */ |
||
51 | 3 | public function __construct(CsvReader $reader, array $filters) |
|
56 | |||
57 | /** |
||
58 | * Run filters against each row. |
||
59 | * Loop through all of the callback functions, and if any of them fail, do |
||
60 | * not include this row in the iteration. |
||
61 | * |
||
62 | * @return bool |
||
63 | * |
||
64 | * @todo filter functions should accept current row, index, AND ref to reader |
||
65 | */ |
||
66 | 3 | public function accept() |
|
77 | |||
78 | /** |
||
79 | * Return this object as an array. |
||
80 | * |
||
81 | * @return array This object as an array |
||
82 | */ |
||
83 | public function toArray() |
||
89 | } |
||
90 |