class Utils
{
/**
- * Generate a token used for RSS
+ * Generate a token used for RSS.
*
* @return string
*/
// 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)));
+ }
}