ApcuCache::fetch()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
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
}