Completed
Push — master ( 9260f2...0fae22 )
by Charles
01:40
created

RPQComponent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getClient() 0 4 1
A getQueue() 0 4 1
A init() 0 7 1
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
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, ...is->redis['namespace']) of type object<RPQ\Client> is incompatible with the declared type object<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
}