Conditions | 5 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | 6 | public function decrypt(string $payload): string |
|
34 | { |
||
35 | 6 | $this->isEncrypted($payload) ?: throw CryptographyException::notEncrypted(); |
|
36 | 5 | $payload = str_replace(['<ENC>', '</ENC>'], ['', ''], $payload); |
|
37 | 5 | $payload = (string) (base64_decode($payload, true) ?: throw CryptographyException::decodeFailure()); |
|
38 | |||
39 | try { |
||
40 | 4 | return (string) ($this->crypto->decrypt($payload) ?: throw CryptographyException::decryptFailure()); |
|
41 | 1 | } catch (\Throwable $e) { |
|
42 | 1 | throw CryptographyException::fromThrowable($e); |
|
43 | } |
||
46 |