Completed
Push — master ( 53c691...aee4b3 )
by Peter
02:49
created

MemoryPullCommandQueue   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 31
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A publish() 0 6 1
A pull() 0 4 1
1
<?php
2
3
/**
4
 * GpsLab component.
5
 *
6
 * @author    Peter Gribanov <[email protected]>
7
 * @copyright Copyright (c) 2011, Peter Gribanov
8
 * @license   http://opensource.org/licenses/MIT
9
 */
10
11
namespace GpsLab\Component\Command\Queue\Pull;
12
13
use GpsLab\Component\Command\Command;
14
15
class MemoryPullCommandQueue implements PullCommandQueue
16
{
17
    /**
18
     * @var Command[]
19
     */
20
    private $commands = [];
21
22
    /**
23
     * Publish command to queue.
24
     *
25
     * @param Command $command
26
     *
27
     * @return bool
28
     */
29 1
    public function publish(Command $command)
30
    {
31 1
        $this->commands[] = $command;
32
33 1
        return true;
34
    }
35
36
    /**
37
     * Pop command from queue. Return NULL if queue is empty.
38
     *
39
     * @return Command|null
40
     */
41 1
    public function pull()
42
    {
43 1
        return array_shift($this->commands);
44
    }
45
}
46