PropertyListIterator.php 734 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Property list iterator. Do not instantiate this class directly.
  4. */
  5. class HTMLPurifier_PropertyListIterator extends FilterIterator
  6. {
  7. protected $l;
  8. protected $filter;
  9. /**
  10. * @param $data Array of data to iterate over
  11. * @param $filter Optional prefix to only allow values of
  12. */
  13. public function __construct(Iterator $iterator, $filter = null) {
  14. parent::__construct($iterator);
  15. $this->l = strlen($filter);
  16. $this->filter = $filter;
  17. }
  18. public function accept() {
  19. $key = $this->getInnerIterator()->key();
  20. if( strncmp($key, $this->filter, $this->l) !== 0 ) {
  21. return false;
  22. }
  23. return true;
  24. }
  25. }
  26. // vim: et sw=4 sts=4