| Total Complexity | 5 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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() |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return string |
||
| 70 | */ |
||
| 71 | 12 | public function __toString() |
|
| 76 |