_filterIdentityMap = new Phreamp_Map_Identity(array(), 'Phreamp_Filter_Interface'); $this->addFilters($filters); } /** * Adds an array of filters to the chain * * @param array $filters * @return Phreamp_Filter */ public function addFilters(array $filters = array()) { $this->_filterIdentityMap->addArray($filters); return $this; } /** * Adds a filter to the chain * * @param Phreamp_Filter_Interface $filter * @return Phreamp_Filter */ public function addFilter(Phreamp_Filter_Interface $filter) { $this->_filterIdentityMap->add($filter); return $this; } /** * Checks if a filter is in the chain * * @param scalar|Phreamp_Filter_Interface $item * @return boolean */ public function inChain($item) { $id = $item instanceof Phreamp_Filter_Interface ? $item->getId() : $item; return $this->_filterIdentityMap->contains($id); } /** * Removes a filter from the chain. * * @param scalar|Phreamp_Filter_Interface $item * @return Phreamp_Filter */ public function removeFilter($item) { $id = $item instanceof Phreamp_Filter_Interface ? $item->getId() : $item; $this->_filterIdentityMap->remove($id); return $this; } /** * Runs the value through all the registered filters * * @param mixed $value * @return mixed */ public function filter($value) { foreach ($this->_filterIdentityMap as $filter) { $value = $filter->filter($value); } return $value; } }