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

48 lines
1.0 KiB
PHP
Raw Normal View History

2010-09-08 23:14:17 -04:00
<?php
/**
* This is in almost every respect equivalent to an array except
* that it keeps track of which keys were accessed.
*
* @warning For the sake of backwards compatibility with early versions
* of PHP 5, you must not use the $hash[$key] syntax; if you do
* our version of offsetGet is never called.
*/
class HTMLPurifier_StringHash extends ArrayObject
{
2016-02-09 05:06:17 -05:00
/**
* @type array
*/
2010-09-08 23:14:17 -04:00
protected $accessed = array();
/**
* Retrieves a value, and logs the access.
2016-02-09 05:06:17 -05:00
* @param mixed $index
* @return mixed
2010-09-08 23:14:17 -04:00
*/
2016-02-09 05:06:17 -05:00
public function offsetGet($index)
{
2010-09-08 23:14:17 -04:00
$this->accessed[$index] = true;
return parent::offsetGet($index);
}
/**
* Returns a lookup array of all array indexes that have been accessed.
2016-02-09 05:06:17 -05:00
* @return array in form array($index => true).
2010-09-08 23:14:17 -04:00
*/
2016-02-09 05:06:17 -05:00
public function getAccessed()
{
2010-09-08 23:14:17 -04:00
return $this->accessed;
}
/**
* Resets the access array.
*/
2016-02-09 05:06:17 -05:00
public function resetAccessed()
{
2010-09-08 23:14:17 -04:00
$this->accessed = array();
}
}
// vim: et sw=4 sts=4