00001 <?php
00002
00003
00004
00005
00006
00007
00008 class ConverterChain implements IConverter {
00009 protected $converters = array();
00010 protected $params = array();
00011
00012 public function encode($value, $params = false) {
00013 reset($this->params);
00014 foreach($this->converters as $c) {
00015 $p = current($this->params);
00016 $value = $c->encode($value, $p);
00017 next($this->params);
00018 }
00019 return $value;
00020 }
00021
00022 public function decode($value, $params = false) {
00023 reset($this->params);
00024 foreach($this->converters as $c) {
00025 $p = current($this->params);
00026 $value = $c->decode($value, $p);
00027 next($this->params);
00028 }
00029 return $value;
00030 }
00031
00032
00033
00034
00035
00036
00037
00038 public function append(IConverter $converter, $params = false) {
00039 $this->converters[] = $converter;
00040 $this->params[] = $params;
00041 }
00042 }
00043
00044