Paperyard
CapTwigExtension.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Paperyard\Helpers;
4 
12 class CapTwigExtension extends \Twig_Extension
13 {
14 
15  public function getFilters()
16  {
17  return array(
18  'cap' => new \Twig_SimpleFilter('cap', array($this, 'cap'))
19  );
20  }
21 
22  public function cap($value, $cap)
23  {
24  return ($value > $cap ? $cap : $value);
25  }
26 
27  public function getName()
28  {
29  return 'cap_extention';
30  }
31 }