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.
Passed
Push — master ( 2d0137...54f172 )
by Yong
12:14 queued 08:03
created

RsaKeyPairCredential::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 12
ccs 8
cts 8
cp 1
crap 2
rs 9.9666
1
<?php
2
3
namespace AlibabaCloud\Client\Credentials;
4
5
use Exception;
6
use AlibabaCloud\Client\SDK;
7
use AlibabaCloud\Client\Filter\CredentialFilter;
8
use AlibabaCloud\Client\Exception\ClientException;
9
10
/**
11
 * Use the RSA key pair to complete the authentication (supported only on Japanese site)
12
 *
13
 * @package   AlibabaCloud\Client\Credentials
14
 */
15
class RsaKeyPairCredential implements CredentialsInterface
16
{
17
18
    /**
19
     * @var string
20
     */
21
    private $publicKeyId;
22
23
    /**
24
     * @var string
25
     */
26
    private $privateKey;
27
28
    /**
29
     * RsaKeyPairCredential constructor.
30
     *
31
     * @param string $publicKeyId
32
     * @param string $privateKeyFile
33
     *
34
     * @throws ClientException
35
     */
36 24
    public function __construct($publicKeyId, $privateKeyFile)
37
    {
38 24
        CredentialFilter::publicKeyId($publicKeyId);
39 20
        CredentialFilter::privateKeyFile($privateKeyFile);
40
41 16
        $this->publicKeyId = $publicKeyId;
42
        try {
43 16
            $this->privateKey = file_get_contents($privateKeyFile);
44 16
        } catch (Exception $exception) {
45 3
            throw new ClientException(
46 3
                $exception->getMessage(),
47
                SDK::INVALID_CREDENTIAL
48 3
            );
49
        }
50 13
    }
51
52
    /**
53
     * @return mixed
54
     */
55 7
    public function getPrivateKey()
56
    {
57 7
        return $this->privateKey;
58
    }
59
60
    /**
61
     * @return string
62
     */
63 7
    public function getPublicKeyId()
64
    {
65 7
        return $this->publicKeyId;
66
    }
67
68
    /**
69
     * @return string
70
     */
71 12
    public function __toString()
72
    {
73 12
        return "publicKeyId#$this->publicKeyId";
74
    }
75
}
76