Completed
Push — master ( 9390bb...789220 )
by Jonathan
09:28 queued 06:04
created

EnvelopeEncryptingPoolDecorator::validateEncryption()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace Jeskew\Cache;
3
4
use Psr\Cache\CacheItemInterface;
5
use Psr\Cache\CacheItemPoolInterface;
6
7
class EnvelopeEncryptingPoolDecorator extends EncryptingPoolDecorator
8
{
9
    /** @var resource|string */
10
    private $certificate;
11
    /** @var string */
12
    private $key;
13
    /** @var null|string */
14
    private $passPhrase;
15
    /** @var string */
16
    private $cipher;
17
18
    /**
19
     * @param CacheItemPoolInterface $decorated
20
     * @param string|resource $certificate
21
     * @param string $key
22
     * @param string|null $passPhrase
23
     * @param string $cipher
24
     *
25
     * @throws \Psr\Cache\InvalidArgumentException
26
     */
27 441
    public function __construct(
28
        CacheItemPoolInterface $decorated,
29
        $certificate,
30
        $key,
31
        $passPhrase = null,
32
        $cipher = 'aes-256-cbc'
33
    ) {
34 441
        parent::__construct($decorated);
35 441
        $this->cipher = $cipher;
36 441
        $this->certificate = $certificate;
37 441
        $this->key = $key;
38 441
        $this->passPhrase = $passPhrase;
39 441
    }
40
41 135
    protected function decorate(CacheItemInterface $inner)
42
    {
43 135
        return new EnvelopeEncryptingItemDecorator(
44 135
            $inner,
45 135
            $this->certificate,
46 135
            $this->key,
47 135
            $this->passPhrase,
48 135
            $this->cipher
49 135
        );
50
    }
51
}
52