3 namespace Wallabag\CoreBundle\Tools
;
8 * Generate a token used for RSS.
12 public static function generateToken()
14 if (ini_get('open_basedir') === '') {
15 if (strtoupper(substr(PHP_OS
, 0, 3)) === 'WIN') {
16 // alternative to /dev/urandom for Windows
17 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
19 $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
22 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
25 // remove character which can broken the url
26 return str_replace(array('+', '/'), '', $token);
30 * For a given text, we calculate reading time for an article
31 * based on 200 words per minute.
37 public static function getReadingTime($text)
39 return floor(str_word_count(strip_tags($text)) / 200);