Completed
Push — master ( 49a516...79d061 )
by Marco
04:40
created

Apc::__construct()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 15
Code Lines 6

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2.1481

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 4
cts 6
cp 0.6667
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 3
nop 1
crap 2.1481
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 52
    public function __construct(LoggerInterface $logger = null) {
31
32
        try {
33
34 52
            $this->driver = new ApcDriver();
35
36 52
            parent::__construct($logger);
37
38
        } catch (Exception $e) {
39
40
            throw new CacheException($e->getMessage());
41
42
        }
43
44 52
    }
45
46 2
    public function getStats() {
47
48 2
        $info = $this->driver->stats();
49
50 2
        $entries = isset($info['num_entries']) ? $info['num_entries'] : null;
51
52 2
        return new EnhancedCacheItemPoolStats(
53 2
            $this->getId(),
54 2
            $this->driver->getName(),
55 2
            $this->getState(),
56
            $entries,
57 2
            $info
58
        );
59
60
    }
61
62
}
63