fucongcong/framework

View on GitHub
core/Group/Redis/RedisHelper.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
 
namespace Group\Redis;
 
class RedisHelper
{
/**
* 生成hash所需的参数
*
* @param prefix
* @param id
* @return list(string,string)
*/
Avoid variables with short names like $id. Configured minimum length is 3.
public static function hashKey($prefix, $id)
{
if (is_numeric($id)) {
$shang = floor($id / 100);
return [$prefix.':'.$shang, $id % 100];
The method hashKey uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
if (strlen($id) > 2) {
No space found after comma in function call
$shang = substr($id, 0,-2);
return [$prefix.':'.$shang, substr($id, -2)];
The method hashKey uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
return [$prefix.':', $id];
}
}
}
}