| Total Complexity | 3 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | final class Cypher implements CypherInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var AES strategy |
||
| 12 | */ |
||
| 13 | private $strategy; |
||
| 14 | /** |
||
| 15 | * @var string the key to encode/decode |
||
| 16 | */ |
||
| 17 | private $key; |
||
| 18 | /** |
||
| 19 | * Cipher constructor. |
||
| 20 | * |
||
| 21 | * @param $key |
||
| 22 | */ |
||
| 23 | public function __construct($key, $iv) |
||
| 31 | 2 | } |
|
| 32 | 2 | ||
| 33 | /** |
||
| 34 | * {@inheritdoc} |
||
| 35 | */ |
||
| 36 | public function encodeMailMessage(MailMessage $mailMessage) |
||
| 37 | 2 | { |
|
| 38 | $jsonEncodedMailMessage = json_encode($mailMessage, JSON_NUMERIC_CHECK); |
||
| 39 | 2 | $this->strategy->setKey($this->key); |
|
| 40 | 2 | $this->strategy->setIV($this->iv); |
|
| 41 | return base64_encode($this->strategy->encrypt($jsonEncodedMailMessage)); |
||
| 42 | 2 | } |
|
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | public function decodeMailMessage($encodedMailMessage) |
||
| 53 | } |
||
| 54 | } |
||
| 55 |