ApcuCache   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 5
dl 0
loc 16
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fetch() 0 2 2
A store() 0 2 1
A __construct() 0 3 2
1
<?php
2
3
namespace evelikto\di\storage\impl;
4
use evelikto\di\storage\OfflineStorage;
5
6
/** Global storage implementation */
7
class ApcuCache implements OfflineStorage
8
{
9
    /** Just check the precondition - APCu must be installed */
10
    public function __construct() {
11
        if (function_exists('apcu_fetch') === false)
12
            throw new ApcuNotInstalled();
13
    }
14
15
    /** {@inheritdoc} */
16
    public function fetch(string $key) {
17
        return apcu_exists($key) ? apcu_fetch($key) : null;
18
    }
19
20
    /** {@inheritdoc} */
21
    public function store(string $key, $value) {
22
        apcu_store($key, $value);
23
    }
24
}