X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTools%2FUtils.php;h=a16baca97e0a09e27e7c35e7ecafdfdf0131416e;hb=5a166c5c1af645b1b1ba77ba5f2e24094e7b60e8;hp=de97c796bda9f54d2ebc104439465a5864c23f22;hpb=1a93ee423b072ec3bcb0c437cbf9b488bdea245c;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php index de97c796..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 */ @@ -22,6 +22,20 @@ class Utils $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); } - return str_replace('+', '', $token); + // 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); } }