Conditions | 3 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | 3 | public function set($key, $value, $ttl = null): bool |
|
29 | 2 | { |
|
30 | $this->checkReservedCharacters($key); |
||
31 | 3 | if ($ttl instanceof DateInterval) { |
|
32 | 3 | $ttl = (new DateTime('now'))->add($ttl)->getTimeStamp() - time(); |
|
33 | } |
||
34 | |||
35 | 2 | if ($ttl !== null) { |
|
36 | $ttl = ((int) $ttl) + time(); |
||
37 | 2 | } |
|
38 | 2 | ||
39 | 2 | $this->bucket[$key] = [$value, $ttl ?? false]; |
|
40 | 2 | ||
41 | return true; |
||
42 | } |
||
79 |