@@ -38,39 +38,39 @@ |
||
| 38 | 38 | protected $what; |
| 39 | 39 | |
| 40 | 40 | function __construct($s, Text $what) { |
| 41 | - if(preg_match("/^([a-z]+)(\\((.*)\\))?$/",$s, $m)) { |
|
| 41 | + if (preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
|
| 42 | 42 | $this->filter = $m[1]; |
| 43 | - $this->vars = isset($m[3])?explode(',',$m[3]):[]; |
|
| 43 | + $this->vars = isset($m[3]) ? explode(',', $m[3]) : []; |
|
| 44 | 44 | } else { |
| 45 | 45 | throw new ParseError("Unable to parse filter expression \"$s\""); |
| 46 | 46 | } |
| 47 | - if(!in_array($this->filter,['itersplit','round','strtoupper','strtolower','ucfirst'])) { |
|
| 47 | + if (!in_array($this->filter, ['itersplit', 'round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
|
| 48 | 48 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
| 49 | 49 | } |
| 50 | - if($this->filter == "itersplit") { |
|
| 50 | + if ($this->filter == "itersplit") { |
|
| 51 | 51 | $this->filter = "Seufert\\Hamle\\Text\\Filter::iterSplit"; |
| 52 | 52 | } |
| 53 | 53 | $this->what = $what; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | function toHTML($escape = false) { |
| 57 | - if($escape) |
|
| 58 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 57 | + if ($escape) |
|
| 58 | + return "<?=htmlspecialchars(" . $this->toPHP() . ")?>"; |
|
| 59 | 59 | return "<?=" . $this->toPHP() . "?>"; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | function toPHP() { |
| 63 | - $o = [$this->what->toPHPVar()] ; |
|
| 64 | - foreach($this->vars as $v) |
|
| 63 | + $o = [$this->what->toPHPVar()]; |
|
| 64 | + foreach ($this->vars as $v) |
|
| 65 | 65 | $o[] = $this->varToCode($v); |
| 66 | - return "{$this->filter}(" . implode(',',$o) . ")"; |
|
| 66 | + return "{$this->filter}(" . implode(',', $o) . ")"; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | static function iterSplit($v, $sep = ",") { |
| 70 | 70 | $o = []; |
| 71 | - foreach(explode($sep, $v) as $k=>$i) { |
|
| 72 | - if($i) |
|
| 73 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 71 | + foreach (explode($sep, $v) as $k=>$i) { |
|
| 72 | + if ($i) |
|
| 73 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k]; |
|
| 74 | 74 | } |
| 75 | 75 | return new WrapArray($o); |
| 76 | 76 | } |