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

Apc   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

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 37
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

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