mixed) */ private $cache = array(); /** * Appends a rule to the end of the filter set. * * @param ezcLogFilter $filter */ public function appendRule( $filter ) { $this->rules[] = $filter; $this->clearCache(); } /** * Deletes the last rule from the filter set. * * Returns false if the filter set is empty, otherwise true. * * @return bool */ public function deleteLastRule() { if ( sizeof( $this->rules ) > 0 ) { array_pop( $this->rules ); $this->clearCache(); return true; } return false; } /** * Returns the variable assigned to the combination of a severity $severity, source $source, * and category $category. * * @param int $severity * @param string $source * @param string $category * @return mixed */ public function get( $severity, $source, $category ) { // It is likely that the same type of log messages are written after each other. if ( isset( $this->cache[ $severity . "_" . $source . "_" . $category ] ) ) { return $this->cache[ $severity . "_" . $source . "_" . $category ]; } // It is not cached, yet. $total = array(); foreach ( $this->rules as $rule ) { if ( $rule->isMatch( $severity, $source, $category ) ) { $total = array_merge( $total, $rule->getContainer() ); if ( !$rule->shouldContinueProcessing() ) { break; } } } // Add to cache. $this->cache[ $severity . "_" . $source . "_" . $category ] = $total; return $total; } /** * Clears the cache. */ protected function clearCache() { $this->cache = array(); } } ?>