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.
22 public static function getDomainName($url)
24 return parse_url($url, PHP_URL_HOST
);
28 * For a given text, we calculate reading time for an article.
34 public static function getReadingTime($text)
36 return floor(str_word_count(strip_tags($text)) / 200);
39 public function getName()
41 return 'wallabag_extension';