Redis::getTtl()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the PHALCON-EXT package.
5
 *
6
 * (c) Jitendra Adhikari <[email protected]>
7
 *     <https://github.com/adhocore>
8
 *
9
 * Licensed under MIT license.
10
 */
11
12
namespace PhalconExt\Cache;
13
14
use Phalcon\Cache\Backend\Redis as BaseRedis;
0 ignored issues
show
Bug introduced by
The type Phalcon\Cache\Backend\Redis was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Redis as PhpRedis;
16
17
/**
18
 * Redis backend client.
19
 */
20
class Redis extends BaseRedis
21
{
22
    /**
23
     * Get underlying redis connection.
24
     *
25
     * @return null|PhpRedis
26
     */
27
    public function getConnection()
28
    {
29
        if (!$this->_redis) {
30
            $this->_connect();
31
        }
32
33
        return $this->_redis;
34
    }
35
36
    /**
37
     * Get the remaining ttl for given key.
38
     *
39
     * @param string $key
40
     *
41
     * @return int
42
     */
43
    public function getTtl(string $key): int
44
    {
45
        return $this->getConnection()->ttl("_PHCR$key") ?: -1;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getConnect...ttl('_PHCR'.$key) ?: -1 could return the type true which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
46
    }
47
}
48