Completed
Push — master ( 7aadd0...e03480 )
by Jonathan
10s
created

PoolDecorator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 1
A decorate() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Jsq\CacheEncryption\Iron;
3
4
use Jsq\CacheEncryption\PoolDecorator as BasePoolDecorator;
5
use Jsq\Iron;
6
use Jsq\Iron\PasswordInterface;
7
use Psr\Cache\CacheItemInterface;
8
use Psr\Cache\CacheItemPoolInterface;
9
10 View Code Duplication
class PoolDecorator extends BasePoolDecorator
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /** @var PasswordInterface */
13
    private $password;
14
    /** @var string */
15
    private $cipher;
16
17 426
    public function __construct(
18
        CacheItemPoolInterface $decorated,
19
        $password,
20
        $cipher = Iron\Iron::DEFAULT_ENCRYPTION_METHOD
21
    ) {
22 426
        parent::__construct($decorated);
23 426
        $this->password = Iron\normalize_password($password);
24 426
        $this->cipher = $cipher;
25 426
    }
26
27 126
    protected function decorate(CacheItemInterface $inner)
28
    {
29 126
        return new ItemDecorator(
30 126
            $inner,
31 126
            $this->password,
32 126
            $this->cipher
33 126
        );
34
    }
35
}
36