Completed
Push — master ( 89d155...6a85db )
by Dan
13:52 queued 06:12
created

ApcStorage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 49
ccs 0
cts 14
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A has() 0 3 1
A set() 0 4 1
A get() 0 4 1
A delete() 0 6 2
1
<?php
2
3
namespace Ds\Cache;
4
5
/**
6
 * Class MemcacheStorage
7
 * @package Ds\Cache
8
 */
9
class ApcStorage implements CacheStorageInterface
10
{
11
    private $enabled = false;
12
13
    public function __construct()
14
    {
15
        $this->enabled = extension_loaded('apc');
16
    }
17
18
    /**
19
     * @param string $key
20
     * @return bool
21
     */
22
    public function has($key){
23
        return \apc_exists($key);
24
    }
25
26
    /**
27
     * @param string $key
28
     * @param mixed $value
29
     * @param int $expires
30
     * @return void
31
     */
32
    public function set($key, $value, $expires)
33
    {
34
        \apc_store($key, $value, $expires);
35
    }
36
37
    /**
38
     * @param string $key
39
     * @return mixed
40
     */
41
    public function get($key)
42
    {
43
        return \apc_fetch($key);
44
    }
45
46
    /**
47
     * @param string $key
48
     * @return void
49
     */
50
    public function delete($key)
51
    {
52
        if (\apc_exists($key)){
53
            \apc_delete($key);
54
        }
55
    }
56
57
}
58