Completed
Pull Request — master (#11)
by Ankit
03:15
created

AbstractCache::setTtl()   A

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 1
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
    /**
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