@@ -13,9 +13,9 @@ |
||
| 13 | 13 | namespace View; |
| 14 | 14 | |
| 15 | 15 | interface Adapter { |
| 16 | - public function __construct($path=null,$options=[]); |
|
| 17 | - public function render($template,$data=[]); |
|
| 16 | + public function __construct($path = null, $options = []); |
|
| 17 | + public function render($template, $data = []); |
|
| 18 | 18 | public static function exists($path); |
| 19 | - public static function addGlobal($key,$val); |
|
| 19 | + public static function addGlobal($key, $val); |
|
| 20 | 20 | public static function addGlobals(array $defs); |
| 21 | 21 | } |
@@ -27,19 +27,19 @@ |
||
| 27 | 27 | * @param mixed $v (default: null) The array of values exposed in template. |
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | - public static function render($t,$v=null){ |
|
| 31 | - if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t); |
|
| 32 | - for( // Init |
|
| 33 | - $r = $ox = $x = false; |
|
| 34 | - // While |
|
| 35 | - false !== ($x = $y = strpos($t,'{{',$x)); |
|
| 36 | - // Do |
|
| 37 | - $r .= substr($t, $ox, $x-$ox), |
|
| 38 | - $c = substr($t, $x += 2, $l = ( $y = strpos($t,'}}', $x) ) - $x), |
|
| 39 | - $ox = $x += $l + 2, |
|
| 40 | - $r .= Object::fetch(trim($c),$v)?:'' |
|
| 41 | - ); |
|
| 42 | - return $r===false ? $t : $r.substr($t,$ox); |
|
| 43 | - } |
|
| 30 | + public static function render($t,$v=null){ |
|
| 31 | + if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t); |
|
| 32 | + for( // Init |
|
| 33 | + $r = $ox = $x = false; |
|
| 34 | + // While |
|
| 35 | + false !== ($x = $y = strpos($t,'{{',$x)); |
|
| 36 | + // Do |
|
| 37 | + $r .= substr($t, $ox, $x-$ox), |
|
| 38 | + $c = substr($t, $x += 2, $l = ( $y = strpos($t,'}}', $x) ) - $x), |
|
| 39 | + $ox = $x += $l + 2, |
|
| 40 | + $r .= Object::fetch(trim($c),$v)?:'' |
|
| 41 | + ); |
|
| 42 | + return $r===false ? $t : $r.substr($t,$ox); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } /* End of class */ |
@@ -27,19 +27,19 @@ |
||
| 27 | 27 | * @param mixed $v (default: null) The array of values exposed in template. |
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | - public static function render($t,$v=null){ |
|
| 31 | - if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t); |
|
| 32 | - for( // Init |
|
| 30 | + public static function render($t, $v = null) { |
|
| 31 | + if (empty($v)) return preg_replace('/{{[^}]+}}/', '', $t); |
|
| 32 | + for ( // Init |
|
| 33 | 33 | $r = $ox = $x = false; |
| 34 | 34 | // While |
| 35 | - false !== ($x = $y = strpos($t,'{{',$x)); |
|
| 35 | + false !== ($x = $y = strpos($t, '{{', $x)); |
|
| 36 | 36 | // Do |
| 37 | - $r .= substr($t, $ox, $x-$ox), |
|
| 38 | - $c = substr($t, $x += 2, $l = ( $y = strpos($t,'}}', $x) ) - $x), |
|
| 37 | + $r .= substr($t, $ox, $x - $ox), |
|
| 38 | + $c = substr($t, $x += 2, $l = ($y = strpos($t, '}}', $x)) - $x), |
|
| 39 | 39 | $ox = $x += $l + 2, |
| 40 | - $r .= Object::fetch(trim($c),$v)?:'' |
|
| 40 | + $r .= Object::fetch(trim($c), $v) ?: '' |
|
| 41 | 41 | ); |
| 42 | - return $r===false ? $t : $r.substr($t,$ox); |
|
| 42 | + return $r === false ? $t : $r.substr($t, $ox); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | } /* End of class */ |
@@ -27,8 +27,10 @@ |
||
| 27 | 27 | * @param mixed $v (default: null) The array of values exposed in template. |
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | - public static function render($t,$v=null){ |
|
| 31 | - if (empty($v)) return preg_replace('/{{[^}]+}}/','',$t); |
|
| 30 | + public static function render($t,$v=null) { |
|
| 31 | + if (empty($v)) { |
|
| 32 | + return preg_replace('/{{[^}]+}}/','',$t); |
|
| 33 | + } |
|
| 32 | 34 | for( // Init |
| 33 | 35 | $r = $ox = $x = false; |
| 34 | 36 | // While |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | |
| 13 | 13 | class Deferred { |
| 14 | 14 | |
| 15 | - protected $callback; |
|
| 15 | + protected $callback; |
|
| 16 | 16 | |
| 17 | - public function __construct( callable $callback ) { |
|
| 18 | - $this->callback = $callback; |
|
| 19 | - } |
|
| 17 | + public function __construct( callable $callback ) { |
|
| 18 | + $this->callback = $callback; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function __destruct() { |
|
| 22 | - call_user_func( $this->callback ); |
|
| 23 | - } |
|
| 21 | + public function __destruct() { |
|
| 22 | + call_user_func( $this->callback ); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -14,12 +14,12 @@ |
||
| 14 | 14 | |
| 15 | 15 | protected $callback; |
| 16 | 16 | |
| 17 | - public function __construct( callable $callback ) { |
|
| 17 | + public function __construct(callable $callback) { |
|
| 18 | 18 | $this->callback = $callback; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function __destruct() { |
| 22 | - call_user_func( $this->callback ); |
|
| 22 | + call_user_func($this->callback); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |