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

Apcu::__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\SimpleCache\Providers;
2
3
use \Comodojo\Cache\Drivers\Apcu as ApcuDriver;
4
use \Comodojo\Cache\Components\EnhancedCacheItemPoolStats;
5
use \Psr\Log\LoggerInterface;
6
use \Comodojo\Exception\SimpleCacheException;
7
use \Exception;
8
9
/**
10
 * Apcu provider
11
 *
12
 * @package     Comodojo Spare Parts
13
 * @author      Marco Giovinazzi <[email protected]>
14
 * @license     MIT
15
 *
16
 * LICENSE:
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26
27 View Code Duplication
class Apcu 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...
28
29 19
    public function __construct(LoggerInterface $logger = null) {
30
31
        try {
32
33 19
            $this->driver = new ApcuDriver();
34
35 19
            parent::__construct($logger);
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
            $entries,
56 1
            $info
57
        );
58
59
    }
60
61
}
62