RPQComponent::getQueue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace yrc\components;
4
5
use Redis;
6
use RPQ\Client;
7
use yii\base\BaseObject;
8
use Yii;
9
10
final class RPQComponent extends BaseObject
11
{
12
    /**
13
     * @var array $redis
14
     */
15
    public $redis = [
16
        'host' => '127.0.0.1',
17
        'port' => 6379,
18
        'database' => 0,
19
        'namespace' => 'rpq'
20
    ];
21
22
    /**
23
     * @var array $queues
24
     */
25
    public $queues;
26
27
    /**
28
     * @var RPQ\Client $client
0 ignored issues
show
Bug introduced by
The type yrc\components\RPQ\Client was not found. Did you mean RPQ\Client? If so, make sure to prefix the type with \.
Loading history...
29
     */
30
    private $client;
31
32
    /**
33
     * Returns the RPQ Client
34
     * @return RPQ\Client
35
     */
36
    public function getClient()
37
    {
38
        return $this->client;
39
    }
40
41
    /**
42
     * Returns the queue object
43
     * @param string $name
44
     * @return array
45
     */
46
    public function getQueue($name = 'default')
47
    {
48
        return $this->getClient()->getQueue($name);
49
    }
50
51
    public function init()
52
    {
53
        parent::init();
54
        $redis = new Redis;
55
        $redis->connect($this->redis['host'], $this->redis['port']);
56
        $this->client = new Client($redis, $this->redis['namespace']);
0 ignored issues
show
Documentation Bug introduced by
It seems like new RPQ\Client($redis, $this->redis['namespace']) of type RPQ\Client is incompatible with the declared type yrc\components\RPQ\Client of property $client.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
57
    }
58
}
59