src/AppBundle/Common/StringToolkit.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace AppBundle\Common;
class StringToolkit
{
public static function template($string, array $variables)
{
if (empty($variables)) {
return $string;
}
$search = array_keys($variables);
array_walk($search, function (&$item) {
$item = '{{'.$item.'}}';
});
$replace = array_values($variables);
return str_replace($search, $replace, $string);
}
public static function sign($data, $key)
{
if (!is_array($data)) {
$data = (array) $data;
}
ksort($data);
return md5(json_encode($data).$key);
}
public static function secondsToText($value)
{
$minutes = intval($value / 60);
$seconds = $value - $minutes * 60;
return sprintf('%02d', $minutes).':'.sprintf('%02d', $seconds);
}
public static function textToSeconds($text)
{
if (false === strpos($text, ':')) {
return 0;
}
list($minutes, $seconds) = explode(':', $text, 2);
return intval($minutes) * 60 + intval($seconds);
}
public static function plain($text, $length = 0)
{
$text = strip_tags($text);
$text = str_replace(array("\n", "\r", "\t"), '', $text);
$text = str_replace(' ', ' ', $text);
$text = trim($text);
$length = (int) $length;
if (($length > 0) && (mb_strlen($text) > $length)) {
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。