Apcu::remove()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Apcu storing (shared memory)
4
 * User: moyo
5
 * Date: 2018/7/11
6
 * Time: 10:41 AM
7
 */
8
9
namespace Carno\Cache\Stores;
10
11
use Carno\Cache\Contracts\Storing;
12
13
class Apcu implements Storing
14
{
15
    /**
16
     * @param string $key
17
     * @return bool
18
     */
19
    public function has(string $key) : bool
20
    {
21
        return apcu_exists($key);
0 ignored issues
show
Bug Best Practice introduced by
The expression return apcu_exists($key) could return the type string[] which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
22
    }
23
24
    /**
25
     * @param string $key
26
     * @return mixed
27
     */
28
    public function read(string $key)
29
    {
30
        return apcu_fetch($key);
31
    }
32
33
    /**
34
     * @param string $key
35
     * @param mixed $data
36
     * @param int $ttl
37
     * @return bool
38
     */
39
    public function write(string $key, $data, int $ttl = null) : bool
40
    {
41
        return apcu_store($key, $data, $ttl ?? 0);
0 ignored issues
show
Bug Best Practice introduced by
The expression return apcu_store($key, $data, $ttl ?? 0) could return the type array which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
42
    }
43
44
    /**
45
     * @param string $key
46
     * @return bool
47
     */
48
    public function remove(string $key) : bool
49
    {
50
        return apcu_delete($key);
0 ignored issues
show
Bug Best Practice introduced by
The expression return apcu_delete($key) could return the type string[] which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
51
    }
52
}
53