Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| TextEncrypter | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| encrypt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| decrypt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Common\Wrappers; |
| 3 | |
| 4 | use Defuse\Crypto\Crypto; |
| 5 | use SensitiveParameter; |
| 6 | |
| 7 | final class TextEncrypter |
| 8 | { |
| 9 | public function __construct(#[SensitiveParameter] private readonly string $encryptionKey) |
| 10 | { |
| 11 | } |
| 12 | |
| 13 | public function encrypt(string $text): string |
| 14 | { |
| 15 | return Crypto::encryptWithPassword($text, $this->encryptionKey); |
| 16 | } |
| 17 | |
| 18 | public function decrypt(string $encryptedText): string |
| 19 | { |
| 20 | return Crypto::decryptWithPassword($encryptedText, $this->encryptionKey); |
| 21 | } |
| 22 | } |