Completed
Push — 2.0 ( 8b0753...eaa66b )
by Marco
04:57
created

Apc   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 92.5 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 37
loc 40
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 17 17 2
A getStats() 14 15 2

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 namespace Comodojo\Cache\Providers;
2
3
use \Comodojo\Cache\Drivers\Apc as ApcDriver;
4
use \Comodojo\Cache\Item;
5
use \Comodojo\Cache\Components\EnhancedCacheItemPoolStats;
6
use \Psr\Log\LoggerInterface;
7
use \Comodojo\Exception\CacheException;
8
use \Exception;
9
10
/**
11
 * @package     Comodojo Cache
12
 * @author      Marco Giovinazzi <[email protected]>
13
 * @license     MIT
14
 *
15
 * LICENSE:
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
 * THE SOFTWARE.
24
 */
25
26 View Code Duplication
class Apc extends AbstractEnhancedProvider {
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...
27
28 28
    public function __construct(array $properties = [], LoggerInterface $logger = null) {
29
30
        try {
31
32 28
            parent::__construct($properties, $logger);
33
34 28
            $this->driver = new ApcDriver();
35
36 28
            $this->test();
37
38
        } catch (Exception $e) {
39
40
            throw new CacheException($e->getMessage());
41
42
        }
43
44 28
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function getStats() {
50
51 1
        $info = $this->driver->stats();
52
53 1
        $entries = isset($info['num_entries']) ? $info['num_entries'] : null;
54
55 1
        return new EnhancedCacheItemPoolStats(
56 1
            $this->getId(),
57 1
            $this->driver->getName(),
58 1
            $this->getState(),
59 1
            $entries,
60 1
            $info
61
        );
62
63
    }
64
65
}
66