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

ResultQueue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A enqueue() 0 4 1
A dequeue() 0 11 2
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