Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class TrimFilter implements Filtrator
00016 {
00017 const LEFT = 'l';
00018 const RIGHT = 'r';
00019 const BOTH = null;
00020
00021 private $charlist = null;
00022 private $direction = self::BOTH;
00023
00027 public static function create()
00028 {
00029 return new self;
00030 }
00031
00035 public function setLeft()
00036 {
00037 $this->direction = self::LEFT;
00038
00039 return $this;
00040 }
00041
00045 public function setRight()
00046 {
00047 $this->direction = self::RIGHT;
00048
00049 return $this;
00050 }
00051
00055 public function setBoth()
00056 {
00057 $this->direction = self::BOTH;
00058
00059 return $this;
00060 }
00061
00062 public function apply($value)
00063 {
00064 $function = $this->direction.'trim';
00065
00066 return (
00067 $this->charlist
00068 ? $function($value, $this->charlist)
00069 : $function($value)
00070 );
00071 }
00072
00076 public function setCharlist($charlist)
00077 {
00078 $this->charlist = $charlist;
00079
00080 return $this;
00081 }
00082 }
00083 ?>