Debian Codegraph @

vendor/clue/redis-protocol/src/Parser/MessageBuffer.php

raw
1 <?php
2
3 namespace Clue\Redis\Protocol\Parser;
4
5 use UnderflowException;
6
7 class MessageBuffer implements ParserInterface
8 {
9 private $parser;
10 private $incomingQueue = array();
11
12 public function __construct(ParserInterface $parser)
13 {
14 $this->parser = $parser;
15 }
16
17 public function popIncomingModel()
18 {
19 if (!$this->incomingQueue) {
20 throw new UnderflowException('Incoming message queue is empty');
21 }
22 return array_shift($this->incomingQueue);
23 }
24
25 public function hasIncomingModel()
26 {
27 return ($this->incomingQueue) ? true : false;
28 }
29
30 public function pushIncoming($data)
31 {
32 $ret = $this->parser->pushIncoming($data);
33
34 foreach ($ret as $one) {
35 $this->incomingQueue []= $one;
36 }
37
38 return $ret;
39 }
40 }