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

MemoryEventQueue::push()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 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