Completed
Push — master ( 856ad6...a8c7fa )
by Ankit
02:24
created

AbstractCache   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 43
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setTtl() 0 3 1
A getTtl() 0 3 1
A deleteAll() 0 13 4
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
    /**
11
     * Set time to live.
12
     *
13
     * @param int $secs
14
     */
15 2
    public function setTtl(int $secs)
16
    {
17 2
        $this->ttl = $secs;
18 2
    }
19
20
    /**
21
     * {@inheritDoc}
22
     */
23 1
    public function getTtl() : int
24
    {
25 1
        return $this->ttl;
26
    }
27
28
    /**
29
     * Delete all keys.
30
     *
31
     * @param array $keys
32
     *
33
     * @return bool
34
     */
35 2
    public function deleteAll(array $keys) : bool
36
    {
37 2
        if (empty($keys)) {
38 2
            return false;
39
        }
40
41 2
        $status = true;
42
43 2
        foreach ($keys as $key) {
44 2
            $status = $status && $this->delete($key);
45
        }
46
47 2
        return $status;
48
    }
49
}
50