PropertyListIterator.php 865 B

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