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

Apc::__construct()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 17
Code Lines 7

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2.0932

Importance

Changes 0
Metric Value
dl 17
loc 17
ccs 5
cts 7
cp 0.7143
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 4
nop 2
crap 2.0932
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