SHA1   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSHA1() 0 14 2
1
<?php
2
3
namespace OpenOauth\Core\WechatCode;
4
5
use OpenOauth\Core\WechatCode\ErrorCode;
6
7
/**
8
 * SHA1 class
9
 *
10
 * 计算公众平台的消息签名接口.
11
 */
12
class SHA1
13
{
14
    /**
15
     * 用SHA1算法生成安全签名
16
     *
17
     * @param string $token     票据
18
     * @param string $timestamp 时间戳
19
     * @param string $nonce     随机字符串
20
     * @param string $encrypt   密文消息
0 ignored issues
show
Documentation introduced by
There is no parameter named $encrypt. Did you maybe mean $encrypt_msg?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
21
     */
22
    public function getSHA1($token, $timestamp, $nonce, $encrypt_msg)
23
    {
24
        //排序
25
        try {
26
            $array = [$encrypt_msg, $token, $timestamp, $nonce];
27
            sort($array, SORT_STRING);
28
            $str = implode($array);
29
30
            return [ErrorCode::$OK, sha1($str)];
31
        } catch (Exception $e) {
0 ignored issues
show
Bug introduced by
The class OpenOauth\Core\WechatCode\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
32
            //print $e . "\n";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
            return [ErrorCode::$ComputeSignatureError, null];
34
        }
35
    }
36
}
37