3 namespace Wallabag\CoreBundle\Twig\Extension
;
5 class WallabagExtension
extends \Twig_Extension
7 public function getFilters()
10 new \
Twig_SimpleFilter('readingTime', array($this, 'getReadingTime')),
11 new \
Twig_SimpleFilter('domainName', array($this, 'getDomainName')),
16 * Returns the domain name for a URL
21 public static function getDomainName($url)
23 return parse_url($url, PHP_URL_HOST
);
27 * For a given text, we calculate reading time for an article
32 public static function getReadingTime($text)
34 return floor(str_word_count(strip_tags($text)) / 200);
37 public function getName()
39 return 'wallabag_extension';