X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTools%2FUtils.php;h=a16baca97e0a09e27e7c35e7ecafdfdf0131416e;hb=6785f4aa749e381081b93e3db46424cc7475eab8;hp=8fa7449173bb3042abf4950b62278a11e2b418d2;hpb=132f614dee55634f83d858d30759226586807566;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php index 8fa74491..a16baca9 100644 --- a/src/Wallabag/CoreBundle/Tools/Utils.php +++ b/src/Wallabag/CoreBundle/Tools/Utils.php @@ -5,7 +5,7 @@ namespace Wallabag\CoreBundle\Tools; class Utils { /** - * Generate a token used for RSS + * Generate a token used for RSS. * * @return string */ @@ -25,4 +25,17 @@ class Utils // remove character which can broken the url return str_replace(array('+', '/'), '', $token); } + + /** + * 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 floor(str_word_count(strip_tags($text)) / 200); + } }