PoolDecorator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 45
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A decorate() 0 10 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