AbstractCache::getPrefix()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TusPhp\Cache;
4
5
abstract class AbstractCache implements Cacheable
6
{
7
    /** @var int TTL in secs (default 1 day) */
8
    protected $ttl = 86400;
9
10
    /** @var string Prefix for cache keys */
11
    protected $prefix = 'tus:';
12
13
    /**
14
     * Set time to live.
15
     *
16
     * @param int $secs
17
     *
18
     * @return self
19
     */
20 3
    public function setTtl(int $secs) : self
21
    {
22 3
        $this->ttl = $secs;
23
24 3
        return $this;
25
    }
26
27
    /**
28
     * {@inheritDoc}
29
     */
30 1
    public function getTtl() : int
31
    {
32 1
        return $this->ttl;
33
    }
34
35
    /**
36
     * Set cache prefix.
37
     *
38
     * @param string $prefix
39
     *
40
     * @return Cacheable
41
     */
42 5
    public function setPrefix(string $prefix) : Cacheable
43
    {
44 5
        $this->prefix = $prefix;
45
46 5
        return $this;
47
    }
48
49
    /**
50
     * Get cache prefix.
51
     *
52
     * @return string
53
     */
54 3
    public function getPrefix() : string
55
    {
56 3
        return $this->prefix;
57
    }
58
59
    /**
60
     * Delete all keys.
61
     *
62
     * @param array $keys
63
     *
64
     * @return bool
65
     */
66 3
    public function deleteAll(array $keys) : bool
67
    {
68 3
        if (empty($keys)) {
69 3
            return false;
70
        }
71
72 3
        $status = true;
73
74 3
        foreach ($keys as $key) {
75 3
            $status = $status && $this->delete($key);
76
        }
77
78 3
        return $status;
79
    }
80
}
81