Completed
Push — master ( 9bf5de...63a510 )
by Peter
22:57
created

MemoryEventQueue   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

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