Completed
Push — master ( 21bf70...cc5276 )
by Kamil
05:50
created

Executor   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 42
ccs 0
cts 28
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isIdle() 0 4 1
A enqueue() 0 7 1
A dequeue() 0 4 1
A undequeue() 0 6 1
A getConn() 0 4 1
1
<?php
2
3
namespace Dazzle\MySQL;
4
5
use Dazzle\Event\BaseEventEmitter;
6
use SplQueue;
7
8
class Executor extends BaseEventEmitter
9
{
10
    private $client;
11
12
    public $queue;
13
14
    public function __construct($client)
15
    {
16
        $this->client = $client;
17
        $this->queue = new SplQueue();
18
    }
19
20
    public function isIdle()
21
    {
22
        return $this->queue->isEmpty();
23
    }
24
25
    public function enqueue($command)
26
    {
27
        $this->queue->enqueue($command);
28
        $this->emit('new');
29
30
        return $command;
31
    }
32
33
    public function dequeue()
34
    {
35
        return $this->queue->dequeue();
36
    }
37
38
    public function undequeue($command)
39
    {
40
        $this->queue->unshift($command);
41
42
        return $command;
43
    }
44
45
    public function getConn()
46
    {
47
        return $this->client;
48
    }
49
}
50