LegacyEncryptor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 24
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A encrypt() 0 4 1
A decrypt() 0 9 1
A getIdentifier() 0 4 1
1
<?php
2
3
namespace Carnage\EncryptedColumn\Encryptor;
4
5
use Carnage\EncryptedColumn\Exception\PopArtPenguinException;
6
use Carnage\EncryptedColumn\ValueObject\EncryptorIdentity;
7
use Carnage\EncryptedColumn\ValueObject\IdentityInterface;
8
use Carnage\EncryptedColumn\ValueObject\Key;
9
use phpseclib\Crypt\Base;
10
use phpseclib\Crypt\Rijndael;
11
12
class LegacyEncryptor implements EncryptorInterface
13
{
14
    const IDENTITY = 'legacy';
15
16
    public function encrypt($data, Key $key)
17
    {
18
        throw new PopArtPenguinException();
19 1
    }
20
21 1
    public function decrypt($data, Key $key)
22 1
    {
23
        $cipher = new Rijndael(Base::MODE_ECB);
24
        $cipher->setBlockLength(256);
25
        $cipher->setKey($key->getKeyInfo());
26
        $cipher->padding = false;
27
28
        return trim($cipher->decrypt(base64_decode($data)));
29 1
    }
30
31 1
    public function getIdentifier(): IdentityInterface
32 1
    {
33 1
        return new EncryptorIdentity(self::IDENTITY);
34
    }
35
}