for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Flynt\Utils;
use Twig_Extension;
use Twig\TwigFilter;
class TwigReadingTimeExtension extends Twig_Extension
Twig_Extension
If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated annotation
ignore-deprecated
class TwigReadingTimeExtension extends /** @scrutinizer ignore-deprecated */ Twig_Extension
{
public function getName()
return 'ReadingTime';
}
public function getFilters()
return [
new TwigFilter('readingtime', [$this, 'readingtimeFilter'])
];
public function readingtimeFilter($content)
$wordsPerMinute = 200;
$words = str_word_count(strip_tags($content));
$minutesToRead = floor($words / $wordsPerMinute);
$min = ($minutesToRead < 1 ? '1' : $minutesToRead);
return $min;