PropertyListIterator.php 894 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #[\ReturnTypeWillChange]
  29. public function accept()
  30. {
  31. $key = $this->getInnerIterator()->key();
  32. if (strncmp($key, $this->filter, $this->l) !== 0) {
  33. return false;
  34. }
  35. return true;
  36. }
  37. }
  38. // vim: et sw=4 sts=4