Test Setup Failed
Push — master ( 009624...c15db0 )
by Chris
48s
created

LegacyEncryptor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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
}