From 2686457448372543fdf4f1fc54c4fd20f0f02c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 7 Aug 2015 22:20:30 +0200 Subject: store estimated reading time / filters on reading time --- src/Wallabag/CoreBundle/Helper/Tools.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Wallabag/CoreBundle/Helper/Tools.php') diff --git a/src/Wallabag/CoreBundle/Helper/Tools.php b/src/Wallabag/CoreBundle/Helper/Tools.php index be29ab99..d368ee71 100755 --- a/src/Wallabag/CoreBundle/Helper/Tools.php +++ b/src/Wallabag/CoreBundle/Helper/Tools.php @@ -118,4 +118,16 @@ final class Tools return str_replace('+', '', $token); } + + /** + * For a given text, we calculate reading time for an article. + * + * @param $text + * + * @return float + */ + public static function getReadingTime($text) + { + return floor(str_word_count(strip_tags($text)) / 200); + } } -- cgit v1.2.3