public function testHasProtocolVersion() { $msg1 = new Message(array('1')); $this->assertTrue(MessageFactory::hasProtocolVersion($msg1->peek())); $msg2 = new Message(array(-1)); $this->assertFalse(MessageFactory::hasProtocolVersion($msg2->peek())); }
public function testShiftReturnsTheFirstPartAndRemovesIt() { $msg = new Message(array('hello', 'world')); $this->assertEquals('hello', $msg->shift()); $this->assertSame(1, $msg->count()); $this->assertEquals('world', $msg->peek()); }
/** * Creates an instance from the Message. * * @param Message $msg * * @return QueueStatusResponse */ public static function fromMessage(Message $msg) { $queueStatus = array(); while ($msg->peek() !== null) { $action = $msg->shift(); $queueStatus[$action] = array('action' => $action, 'queue' => $msg->shift(), 'busy' => $msg->shift(), 'available' => $msg->shift()); } return new self($queueStatus); }
/** * Creates an instance from the Message. * * @param Message $msg * * @return WorkerStatusResponse */ public static function fromMessage(Message $msg) { $workerStatus = array(); while ($msg->peek() !== null) { $id = $msg->shift(); $actionCount = (int) $msg->shift(); $actionList = array(); for ($i = 0; $i < $actionCount; $i++) { $actionList[] = $msg->shift(); } $workerStatus[$id] = array('id' => $id, 'actionList' => $actionList, 'current' => $msg->shift(), 'ready' => (bool) $msg->shift(), 'valid' => (bool) $msg->shift()); } return new self($workerStatus); }
/** * @param Message $message * * @return boolean */ public static function isProtocolMessage(Message $message) { // Temporary check to maintain BC with legacy Messages. if (is_numeric($message->peek()) && $message->peek() < 100) { return true; } return false; }