Completed
Push — master ( 2ec33a...e1edf3 )
by Akihito
02:29
created

ResultQueue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
namespace Ackintosh\Snidel;
3
4
use Ackintosh\Snidel\AbstractQueue;
5
use Ackintosh\Snidel\Fork;
6
7
class ResultQueue extends AbstractQueue
8
{
9
    /**
10
     * @param   \Ackintosh\Snidel\Fork
11
     */
12
    public function enqueue($fork)
13
    {
14
        return $this->sendMessage(Fork::serialize($fork));
15
    }
16
17
    /**
18
     * @return  \Ackintosh\Snidel\Fork
19
     * @throws  \RuntimeException
20
     */
21
    public function dequeue()
22
    {
23
        $this->dequeuedCount++;
24
        try {
25
        $serializedFork = $this->receiveMessage();
26
        } catch (\RuntimeException $e) {
27
            throw new \RuntimeException('failed to dequeue result');
28
        }
29
30
        return Fork::unserialize($serializedFork);
31
    }
32
}
33