Completed
Push — 2.0 ( a52f91...c9f4d8 )
by Marco
12:16
created

Apc::status()   B

Complexity

Conditions 6
Paths 13

Size

Total Lines 32
Code Lines 17

Duplication

Lines 6
Ratio 18.75 %

Code Coverage

Tests 10
CRAP Score 8.5139

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 32
ccs 10
cts 17
cp 0.5881
rs 8.439
cc 6
eloc 17
nc 13
nop 0
crap 8.5139
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
 * Apcu provider
12
 *
13
 * @package     Comodojo Spare Parts
14
 * @author      Marco Giovinazzi <[email protected]>
15
 * @license     MIT
16
 *
17
 * LICENSE:
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 * THE SOFTWARE.
26
 */
27
28 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...
29
30
    public function __construct(LoggerInterface $logger = null) {
31
32
        try {
33
34
            $this->driver = new ApcDriver();
35 18
36
            parent::__construct($logger);
37 18
38
        } catch (Exception $e) {
39 18
40
            throw new CacheException($e->getMessage());
41
42
        }
43
44
    }
45
46
    public function getStats() {
47
48
        $info = $this->driver->stats();
49 18
50 18
        $entries = isset($info['num_entries']) ? $info['num_entries'] : null;
51 18
52
        return new EnhancedCacheItemPoolStats(
53
            $this->getId(),
54
            $this->driver->getName(),
55 18
            $this->getState(),
56
            $entries,
57
            $info
58
        );
59
60 32
    }
61
62
}
63