PoolDecorator::decorate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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