Conditions | 1 |
Paths | 1 |
Total Lines | 90 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
188 | protected function getDefaultFunctions($object) |
||
189 | { |
||
190 | $functions = array(); |
||
191 | |||
192 | $functions[] = new \Twig_SimpleFunction('error', function ($key = null, $has_error = null, $no_error = '') use ($object) { |
||
193 | return $object->error($key, $has_error, $no_error); |
||
194 | }, array('is_safe' => array('all'))); |
||
195 | |||
196 | $functions[] = new \Twig_SimpleFunction('text', function ($text, $arguments = array()) use ($object) { |
||
197 | return $object->text($text, $arguments); |
||
198 | }, array('is_safe' => array('all'))); |
||
199 | |||
200 | $functions[] = new \Twig_SimpleFunction('access', function ($permission) use ($object) { |
||
201 | return $object->access($permission); |
||
202 | }); |
||
203 | |||
204 | $functions[] = new \Twig_SimpleFunction('url', function ($path = '', array $query = array(), $absolute = false) use ($object) { |
||
205 | return $object->url($path, $query, $absolute); |
||
206 | }); |
||
207 | |||
208 | $functions[] = new \Twig_SimpleFunction('isSuperadmin', function ($user_id = null) use ($object) { |
||
209 | return $object->isSuperadmin($user_id); |
||
210 | }); |
||
211 | |||
212 | $functions[] = new \Twig_SimpleFunction('date', function ($timestamp = null, $full = true, $unix_format = '') use ($object) { |
||
213 | return $object->date($timestamp, $full, $unix_format); |
||
214 | }); |
||
215 | |||
216 | $functions[] = new \Twig_SimpleFunction('attributes', function ($attributes) use ($object) { |
||
217 | return $object->attributes($attributes); |
||
218 | }, array('is_safe' => array('all'))); |
||
219 | |||
220 | $functions[] = new \Twig_SimpleFunction('config', function ($key = null, $default = null) use ($object) { |
||
221 | return $object->config($key, $default); |
||
222 | }); |
||
223 | |||
224 | $functions[] = new \Twig_SimpleFunction('settings', function ($key = null, $default = null) use ($object) { |
||
225 | return $object->settings($key, $default); |
||
226 | }); |
||
227 | |||
228 | $functions[] = new \Twig_SimpleFunction('summary', function ($text, $xss = false, $filter = null) use ($object) { |
||
229 | return $object->summary($text, $xss, $filter); |
||
230 | }, array('is_safe' => array('all'))); |
||
231 | |||
232 | $functions[] = new \Twig_SimpleFunction('user', function ($item = null) use ($object) { |
||
233 | return $object->user($item); |
||
234 | }); |
||
235 | |||
236 | $functions[] = new \Twig_SimpleFunction('store', function ($item = null) use ($object) { |
||
237 | return $object->store($item); |
||
238 | }); |
||
239 | |||
240 | $functions[] = new \Twig_SimpleFunction('d', function ($key = null) use ($object) { |
||
241 | d($object->getData($key)); |
||
242 | }); |
||
243 | |||
244 | $functions[] = new \Twig_SimpleFunction('xss', function ($text, $filter = null) use ($object) { |
||
245 | return $object->xss($text, $filter); |
||
246 | }, array('is_safe' => array('all'))); |
||
247 | |||
248 | $functions[] = new \Twig_SimpleFunction('truncate', function ($string, $length = 100, $trimmarker = '...') use ($object) { |
||
249 | return $object->truncate($string, $length, $trimmarker); |
||
250 | }); |
||
251 | |||
252 | $functions[] = new \Twig_SimpleFunction('cart', function ($key = null) use ($object) { |
||
253 | return $object->cart($key); |
||
254 | }); |
||
255 | |||
256 | $functions[] = new \Twig_SimpleFunction('compare', function ($key = null) use ($object) { |
||
257 | return $object->compare($key); |
||
258 | }); |
||
259 | |||
260 | $functions[] = new \Twig_SimpleFunction('wishlist', function ($key = null) use ($object) { |
||
261 | return $object->wishlist($key); |
||
262 | }); |
||
263 | |||
264 | $functions[] = new \Twig_SimpleFunction('menu', function (array $options = array()) use ($object) { |
||
265 | return $object->menu($options); |
||
266 | }, array('is_safe' => array('all'))); |
||
267 | |||
268 | $functions[] = new \Twig_SimpleFunction('prop', function ($name) use ($object) { |
||
269 | return $object->prop($name); |
||
270 | }); |
||
271 | |||
272 | $functions[] = new \Twig_SimpleFunction('path', function ($path = null) use ($object) { |
||
273 | return $object->path($path); |
||
274 | }); |
||
275 | |||
276 | return $functions; |
||
277 | } |
||
278 | |||
312 |