GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ShaHmac256WithRsaSignature   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 52
ccs 18
cts 18
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 0 3 1
A getVersion() 0 3 1
A getType() 0 3 1
A sign() 0 18 2
1
<?php
2
3
namespace AlibabaCloud\Client\Signature;
4
5
use Exception;
6
use AlibabaCloud\Client\SDK;
7
use AlibabaCloud\Client\Exception\ClientException;
8
9
/**
10
 * Class ShaHmac256WithRsaSignature
11
 *
12
 * @package   AlibabaCloud\Signature
13
 */
14
class ShaHmac256WithRsaSignature extends Signature implements SignatureInterface
15
{
16
17
    /**
18
     * @return string
19
     */
20 6
    public function getMethod()
21
    {
22 6
        return 'SHA256withRSA';
23
    }
24
25
    /**
26
     * @return string
27
     */
28 6
    public function getType()
29
    {
30 6
        return 'PRIVATEKEY';
31
    }
32
33
    /**
34
     * @return string
35
     */
36 6
    public function getVersion()
37
    {
38 6
        return '1.0';
39
    }
40
41
    /**
42
     * @param string $string
43
     * @param string $privateKey
44
     *
45
     * @return string
46
     * @throws ClientException
47
     */
48 7
    public function sign($string, $privateKey)
49
    {
50 7
        $binarySignature = '';
51
        try {
52 7
            openssl_sign(
53 7
                $string,
54 7
                $binarySignature,
55 7
                $privateKey,
56
                \OPENSSL_ALGO_SHA256
57 7
            );
58 7
        } catch (Exception $exception) {
59 2
            throw  new ClientException(
60 2
                $exception->getMessage(),
61
                SDK::INVALID_CREDENTIAL
62 2
            );
63
        }
64
65 5
        return base64_encode($binarySignature);
66
    }
67
}
68