@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | date_default_timezone_set('Asia/Shanghai'); |
| 59 | 59 | $msec = 0; |
| 60 | 60 | list($msec, $sec) = explode(' ', microtime()); |
| 61 | - return (float)sprintf('%.0f', ((float)$msec + (float)$sec) * 1000); |
|
| 61 | + return (float)sprintf('%.0f', ((float)$msec+(float)$sec)*1000); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | date_default_timezone_set('Asia/Shanghai'); |
| 73 | 73 | $end_time = strtotime($end_time); |
| 74 | 74 | $start_time = $start_time === '' ? time() : strtotime($start_time); |
| 75 | - return $end_time - $start_time; |
|
| 75 | + return $end_time-$start_time; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if (empty($time)) { |
| 112 | 112 | $time = time(); |
| 113 | 113 | } |
| 114 | - return date($format, $time - $mun); |
|
| 114 | + return date($format, $time-$mun); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | if (empty($time)) { |
| 128 | 128 | $time = time(); |
| 129 | 129 | } |
| 130 | - return date($format, $time + $mun); |
|
| 130 | + return date($format, $time+$mun); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | { |
| 142 | 142 | date_default_timezone_set('Asia/Shanghai'); |
| 143 | 143 | $date = date('H:i'); |
| 144 | - $curTime = strtotime($date);//当前时分 |
|
| 145 | - $assignTime1 = strtotime($start);//获得指定分钟时间戳,00:00 |
|
| 146 | - $assignTime2 = strtotime($end);//获得指定分钟时间戳,01:00 |
|
| 144 | + $curTime = strtotime($date); //当前时分 |
|
| 145 | + $assignTime1 = strtotime($start); //获得指定分钟时间戳,00:00 |
|
| 146 | + $assignTime2 = strtotime($end); //获得指定分钟时间戳,01:00 |
|
| 147 | 147 | $result = false; |
| 148 | 148 | if ($curTime > $assignTime1 && $curTime < $assignTime2) { |
| 149 | 149 | $result = true; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function isEvenNumbers(int $num): bool |
| 37 | 37 | { |
| 38 | - return $num % 2 === 0; |
|
| 38 | + return $num%2 === 0; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -45,6 +45,6 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function isOddNumbers(int $num): bool |
| 47 | 47 | { |
| 48 | - return !($num % 2 === 0); |
|
| 48 | + return !($num%2 === 0); |
|
| 49 | 49 | } |
| 50 | 50 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile', 'alipay' |
| 130 | 130 | ]; |
| 131 | 131 | // 从HTTP_USER_AGENT中查找手机浏览器的关键字 |
| 132 | - if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower(request()->server('HTTP_USER_AGENT')))) { |
|
| 132 | + if (preg_match("/(".implode('|', $clientkeywords).")/i", strtolower(request()->server('HTTP_USER_AGENT')))) { |
|
| 133 | 133 | return true; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $agent = strtolower(request()->server('HTTP_USER_AGENT')); |
| 202 | 202 | if (strpos($agent, 'iphone') || strpos($agent, 'ipad') || strpos($agent, 'android')) { |
| 203 | 203 | $type = 'mobile'; |
| 204 | - } else { |
|
| 204 | + }else { |
|
| 205 | 205 | $type = 'computer'; |
| 206 | 206 | } |
| 207 | 207 | return $type; |
@@ -231,6 +231,6 @@ discard block |
||
| 231 | 231 | public function getWebsiteAddress(): string |
| 232 | 232 | { |
| 233 | 233 | $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')) ? 'https://' : 'http://'; |
| 234 | - return $http_type . $_SERVER['HTTP_HOST'] . "/"; |
|
| 234 | + return $http_type.$_SERVER['HTTP_HOST']."/"; |
|
| 235 | 235 | } |
| 236 | 236 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $buff = ""; |
| 65 | 65 | foreach ($data as $k => $v) { |
| 66 | 66 | if ($k !== "sign" && $v !== "" && !is_array($v)) { |
| 67 | - $buff .= $k . "=" . $v . "&"; |
|
| 67 | + $buff .= $k."=".$v."&"; |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | $buff = trim($buff, "&"); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | $dh = opendir($name); |
| 68 | 68 | while ($file = readdir($dh)) { |
| 69 | 69 | if ($file !== "." && $file !== "..") { |
| 70 | - $fullpath = $name . "/" . $file; |
|
| 70 | + $fullpath = $name."/".$file; |
|
| 71 | 71 | if (!is_dir($fullpath)) { |
| 72 | 72 | unlink($fullpath); |
| 73 | - } else { |
|
| 73 | + }else { |
|
| 74 | 74 | $this->deletes($fullpath); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if (empty($name)) { |
| 98 | 98 | throw new DtaException('请检查需要打包的路径名称'); |
| 99 | 99 | } |
| 100 | - $list = glob($name . "{$file_name}.{$suffix_name}"); |
|
| 100 | + $list = glob($name."{$file_name}.{$suffix_name}"); |
|
| 101 | 101 | $fileList = $list; |
| 102 | 102 | $zip = new ZipArchive(); |
| 103 | 103 | // 打开压缩包 |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $files = []; |
| 122 | 122 | if (is_dir($path)) { |
| 123 | - $path = dirname($path) . '/' . basename($path) . '/'; |
|
| 123 | + $path = dirname($path).'/'.basename($path).'/'; |
|
| 124 | 124 | $file = dir($path); |
| 125 | 125 | while (false !== ($entry = $file->read())) { |
| 126 | 126 | if ($entry !== '.' && $entry !== '..') { |
| 127 | - $cur = $path . $entry; |
|
| 127 | + $cur = $path.$entry; |
|
| 128 | 128 | if (is_dir($cur)) { |
| 129 | - $subPath = $cur . '/'; |
|
| 129 | + $subPath = $cur.'/'; |
|
| 130 | 130 | $this->getFiles($subPath); |
| 131 | 131 | } |
| 132 | 132 | $files[] = $cur; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
| 18 | 18 | // +---------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | -declare (strict_types=1); |
|
| 20 | +declare(strict_types=1); |
|
| 21 | 21 | |
| 22 | 22 | namespace DtApp\ThinkLibrary\helper; |
| 23 | 23 | |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | $charset = array_merge($lowerLetter, $upperLetter); |
| 59 | 59 | } elseif ($type === 7) { |
| 60 | 60 | $charset = array_merge($number, $lowerLetter, $upperLetter); |
| 61 | - } else { |
|
| 61 | + }else { |
|
| 62 | 62 | $charset = $number; |
| 63 | 63 | } |
| 64 | 64 | $str = ''; |
| 65 | 65 | // 生成字符串 |
| 66 | 66 | for ($i = 0; $i < $length; $i++) { |
| 67 | - $str .= $charset[random_int(0, count($charset) - 1)]; |
|
| 67 | + $str .= $charset[random_int(0, count($charset)-1)]; |
|
| 68 | 68 | // 验证规则 |
| 69 | 69 | if ($type === 4 && strlen($str) >= 2) { |
| 70 | 70 | if (!preg_match('/\d+/', $str) || !preg_match('/[a-z]+/', $str)) { |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | { |
| 244 | 244 | //组织参数 |
| 245 | 245 | $strParam = $this->createStrParam(); |
| 246 | - $result = file_get_contents($this->api_url . "?{$strParam}"); |
|
| 246 | + $result = file_get_contents($this->api_url."?{$strParam}"); |
|
| 247 | 247 | $result = json_decode($result, true); |
| 248 | 248 | $this->output = $result; |
| 249 | 249 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $strParam = ''; |
| 258 | 258 | foreach ($this->param as $key => $val) { |
| 259 | 259 | if ($key !== '' && $val !== '') { |
| 260 | - $strParam .= $key . '=' . urlencode($val) . '&'; |
|
| 260 | + $strParam .= $key.'='.urlencode($val).'&'; |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | return $strParam; |
@@ -210,8 +210,8 @@ |
||
| 210 | 210 | //生成签名 |
| 211 | 211 | $sign = $this->createSign(); |
| 212 | 212 | //组织参数 |
| 213 | - $this->param .= '&userkey=' . $sign; |
|
| 214 | - $url = "http://" . $this->api . "/" . $this->method . ".do?{$this->param}"; |
|
| 213 | + $this->param .= '&userkey='.$sign; |
|
| 214 | + $url = "http://".$this->api."/".$this->method.".do?{$this->param}"; |
|
| 215 | 215 | $result = file_get_contents($url); |
| 216 | 216 | $result = Xmls::toArray($result); |
| 217 | 217 | $this->output = $result; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | { |
| 312 | 312 | if (is_object($object)) { |
| 313 | 313 | $arr = (array)($object); |
| 314 | - } else { |
|
| 314 | + }else { |
|
| 315 | 315 | $arr = &$object; |
| 316 | 316 | } |
| 317 | 317 | if (is_array($arr)) { |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | $recToken = $auth->authorizationV2($this->url, $this->method, json_encode($this->param), $this->contentType); |
| 346 | 346 | $rtcToken['Content-Type'] = $this->contentType; |
| 347 | 347 | dump($recToken); |
| 348 | - dump($this->url . "?" . http_build_query($this->param)); |
|
| 349 | - $ret = Client::get($this->url . "?" . http_build_query($this->param), $recToken); |
|
| 348 | + dump($this->url."?".http_build_query($this->param)); |
|
| 349 | + $ret = Client::get($this->url."?".http_build_query($this->param), $recToken); |
|
| 350 | 350 | dump($ret); |
| 351 | 351 | $this->output = $ret->json(); |
| 352 | 352 | return $this; |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $url = parse_url($this->url); |
| 363 | 363 | $data = $url['path'] ?? ''; |
| 364 | 364 | if (isset($url['query'])) { |
| 365 | - $data .= '?' . $url['query']; |
|
| 365 | + $data .= '?'.$url['query']; |
|
| 366 | 366 | } |
| 367 | 367 | $data .= "\n"; |
| 368 | 368 | if (isset($this->param) && $this->contentType === 'application/x-www-form-urlencoded') { |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | private function sign($data) |
| 379 | 379 | { |
| 380 | 380 | $sign = hash_hmac('sha1', $data, $this->secretKey, true); |
| 381 | - return "Qiniu " . sprintf('%s:%s', $this->accessKey, $this->encode($sign)); |
|
| 381 | + return "Qiniu ".sprintf('%s:%s', $this->accessKey, $this->encode($sign)); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |