Skip to content

Commit baf4bf7

Browse files
committed
optimize
1 parent ad1f9f2 commit baf4bf7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Plugin.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,25 @@ public static function change_description($class)
7676
$class->random = htmlspecialchars(self::get_random_string());
7777
}
7878

79-
public static function get_random_string(){
79+
public static function get_random_string()
80+
{
8081
$config = Helper::options()->plugin('RandomDescription');
81-
if(empty($config->description)){
82+
if (empty($config->description)) {
8283
return Helper::options()->description;
8384
}
84-
if(time() - $config->last_time > $config->interval){
85+
if (time() - $config->last_time > $config->interval) {
8586
$string = self::gen_string_from($config->description);
8687
$time = array('last_time' => time(), 'last_string' => $string);
8788
Helper::configPlugin('RandomDescription', $time);
8889
return $string;
89-
}else{
90+
} else {
9091
return $config->last_string;
9192
}
9293
}
9394

94-
public static function gen_string_from($description){
95-
$str_array = explode("\n",$description);
95+
public static function gen_string_from($description)
96+
{
97+
$str_array = explode("\n", $description);
9698
$key = array_rand($str_array);
9799
return $str_array[$key];
98100
}

0 commit comments

Comments
 (0)