X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTools%2FUtils.php;h=b146d98b9c360dfd64a7da1057f9fc3f5d065219;hb=1f4408de9ed08f3b0fda45a93f1585c80feeb21d;hp=7e2968e77f45153fc55178fd9bac190450a7bb5a;hpb=4346a86068781f4acdeb574d7e2af08b77b58ea7;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php index 7e2968e7..b146d98b 100644 --- a/src/Wallabag/CoreBundle/Tools/Utils.php +++ b/src/Wallabag/CoreBundle/Tools/Utils.php @@ -25,4 +25,26 @@ class Utils // remove character which can broken the url return str_replace(array('+', '/'), '', $token); } + + /** + * @param $words + * @return float + */ + public static function convertWordsToMinutes($words) + { + return floor($words / 200); + } + + /** + * For a given text, we calculate reading time for an article + * based on 200 words per minute. + * + * @param $text + * + * @return float + */ + public static function getReadingTime($text) + { + return self::convertWordsToMinutes(str_word_count(strip_tags($text))); + } }