friendica/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php

43 lines
865 B
PHP
Raw Normal View History

2010-09-09 05:14:17 +02:00
<?php
/**
* Property list iterator. Do not instantiate this class directly.
*/
class HTMLPurifier_PropertyListIterator extends FilterIterator
{
2016-02-09 11:06:17 +01:00
/**
* @type int
*/
2010-09-09 05:14:17 +02:00
protected $l;
2016-02-09 11:06:17 +01:00
/**
* @type string
*/
2010-09-09 05:14:17 +02:00
protected $filter;
/**
2016-02-09 11:06:17 +01:00
* @param Iterator $iterator Array of data to iterate over
* @param string $filter Optional prefix to only allow values of
2010-09-09 05:14:17 +02:00
*/
2016-02-09 11:06:17 +01:00
public function __construct(Iterator $iterator, $filter = null)
{
2010-09-09 05:14:17 +02:00
parent::__construct($iterator);
$this->l = strlen($filter);
$this->filter = $filter;
}
2016-02-09 11:06:17 +01:00
/**
* @return bool
*/
public function accept()
{
2010-09-09 05:14:17 +02:00
$key = $this->getInnerIterator()->key();
2016-02-09 11:06:17 +01:00
if (strncmp($key, $this->filter, $this->l) !== 0) {
2010-09-09 05:14:17 +02:00
return false;
}
return true;
}
}
// vim: et sw=4 sts=4