diff --git a/lib/Predis/Commands/Preprocessors/ICommandPreprocessorChain.php b/lib/Predis/Commands/Preprocessors/ICommandPreprocessorChain.php new file mode 100644 index 00000000..e5211b52 --- /dev/null +++ b/lib/Predis/Commands/Preprocessors/ICommandPreprocessorChain.php @@ -0,0 +1,11 @@ +add($preprocessor); + } + } + + public function add(ICommandPreprocessor $preprocessor) { + $this->_preprocessors[] = $preprocessor; + } + + public function remove(ICommandPreprocessor $preprocessor) { + // TODO: find index of value + } + + public function process(&$method, &$arguments) { + $count = count($this->_preprocessors); + for ($i = 0; $i < $count; $i++) { + $this->_preprocessors[$i]->process($method, $arguments); + } + } + + public function getPreprocessors() { + return $this->_preprocessors; + } + + public function getIterator() { + return new \ArrayIterator($this->_preprocessors); + } + + public function count() { + return count($this->_preprocessors); + } + + public function offsetExists($index) { + return isset($this->_preprocessors[$index]); + } + + public function offsetGet($index) { + return $this->_preprocessors[$index]; + } + + public function offsetSet($index, $preprocessor) { + $this->_preprocessors[$index] = $preprocessor; + } + + public function offsetUnset($index) { + unset($this->_preprocessors[$index]); + } +}