blob: 71cbc490dd48119a218b1b829f6be4be9c08da57 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
namespace Wallabag\CoreBundle\Tools;
class Utils
{
/**
* Generate a token used for RSS.
*
* @param integer $length Length of the token
*
* @return string
*/
public static function generateToken($length = 15)
{
$token = substr(base64_encode(random_bytes($length)), 0, $length);
// 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);
}
}
|