@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | public function __toString() { |
11 | 11 | try { |
12 | - return (string)$this->call(); |
|
12 | + return (string) $this->call(); |
|
13 | 13 | } catch (Exception $e) { |
14 | 14 | return 'Caught exception: ' . $e->getMessage() . "\n"; |
15 | 15 | } |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * @param array $args |
23 | 23 | * @param bool $return_output_buffer |
24 | 24 | */ |
25 | - public function __construct( $function, $args = array(), $return_output_buffer = false ) { |
|
26 | - if( is_array( $function ) ) { |
|
27 | - if( (is_string( $function[0] ) && class_exists( $function[0] ) ) || gettype( $function[0] ) === 'object' ) { |
|
25 | + public function __construct($function, $args = array(), $return_output_buffer = false) { |
|
26 | + if ( is_array($function) ) { |
|
27 | + if ( (is_string($function[0]) && class_exists($function[0])) || gettype($function[0]) === 'object' ) { |
|
28 | 28 | $this->_class = $function[0]; |
29 | 29 | } |
30 | 30 | |
31 | - if( is_string( $function[1] ) ) $this->_function = $function[1]; |
|
31 | + if ( is_string($function[1]) ) $this->_function = $function[1]; |
|
32 | 32 | } else { |
33 | 33 | $this->_function = $function; |
34 | 34 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $this->_args = $args; |
37 | 37 | $this->_use_ob = $return_output_buffer; |
38 | 38 | |
39 | - add_filter( 'get_twig', array( &$this, 'add_to_twig' ) ); |
|
39 | + add_filter('get_twig', array(&$this, 'add_to_twig')); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * @param Twig_Environment $twig |
46 | 46 | * @return Twig_Environment |
47 | 47 | */ |
48 | - public function add_to_twig( $twig ) { |
|
48 | + public function add_to_twig($twig) { |
|
49 | 49 | $wrapper = $this; |
50 | 50 | |
51 | - $twig->addFunction( new Twig_SimpleFunction( $this->_function, function () use ( $wrapper ) { |
|
52 | - return call_user_func_array( array( $wrapper, 'call' ), func_get_args() ); |
|
53 | - } ) ); |
|
51 | + $twig->addFunction(new Twig_SimpleFunction($this->_function, function() use ($wrapper) { |
|
52 | + return call_user_func_array(array($wrapper, 'call'), func_get_args()); |
|
53 | + } )); |
|
54 | 54 | |
55 | 55 | return $twig; |
56 | 56 | } |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * @return string |
62 | 62 | */ |
63 | 63 | public function call() { |
64 | - $args = $this->_parse_args( func_get_args(), $this->_args ); |
|
65 | - $callable = ( isset( $this->_class ) ) ? array( $this->_class, $this->_function ) : $this->_function; |
|
64 | + $args = $this->_parse_args(func_get_args(), $this->_args); |
|
65 | + $callable = (isset($this->_class)) ? array($this->_class, $this->_function) : $this->_function; |
|
66 | 66 | |
67 | 67 | if ( $this->_use_ob ) { |
68 | - return TimberHelper::ob_function( $callable, $args ); |
|
68 | + return TimberHelper::ob_function($callable, $args); |
|
69 | 69 | } else { |
70 | - return call_user_func_array( $callable, $args ); |
|
70 | + return call_user_func_array($callable, $args); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | * @param array $defaults |
79 | 79 | * @return array |
80 | 80 | */ |
81 | - private function _parse_args( $args, $defaults ) { |
|
82 | - $_arg = reset( $defaults ); |
|
81 | + private function _parse_args($args, $defaults) { |
|
82 | + $_arg = reset($defaults); |
|
83 | 83 | |
84 | - foreach ( $args as $index => $arg ) { |
|
85 | - $defaults[$index] = is_null( $arg ) ? $_arg : $arg; |
|
86 | - $_arg = next( $defaults ); |
|
84 | + foreach ($args as $index => $arg) { |
|
85 | + $defaults[$index] = is_null($arg) ? $_arg : $arg; |
|
86 | + $_arg = next($defaults); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $defaults; |
@@ -28,7 +28,9 @@ |
||
28 | 28 | $this->_class = $function[0]; |
29 | 29 | } |
30 | 30 | |
31 | - if( is_string( $function[1] ) ) $this->_function = $function[1]; |
|
31 | + if( is_string( $function[1] ) ) { |
|
32 | + $this->_function = $function[1]; |
|
33 | + } |
|
32 | 34 | } else { |
33 | 35 | $this->_function = $function; |
34 | 36 | } |