public function __construct(\ZMQSocket $socket) { if ($socket->getSocketType() !== \ZMQ::SOCKET_REP) { throw new \InvalidArgumentException('Invalid socket type. REP required'); } $this->socket = $socket; }
/** * @param RawZMQSocket $socket * @return ZmqSocket */ private function wrapSocket(RawZMQSocket $socket) { $wrapped = new ZmqSocket($socket, $this->loop); if ($this->isReadableSocketType($socket->getSocketType())) { $wrapped->attachReadListener(); } return $wrapped; }
/** * @return bool */ public function handlesDeferred() { return $this->socket->getSocketType() === \ZMQ::SOCKET_REQ; }
/** * @param \ZMQSocket $socket * * @return bool */ protected function isSocketTypeWaitingForReply(\ZMQSocket $socket) { switch ($socket->getSocketType()) { case \ZMQ::SOCKET_REP: return true; default: return false; } }
private function getContextMock($methods = array(), \ZMQSocket $socket = null) { $context = $this->getMockBuilder('\\ZMQContext')->setConstructorArgs(array(1, $socket->isPersistent()))->setMethods($methods)->getMock(); if ($socket) { $context->expects($this->any())->method('getSocket')->with($this->equalTo($socket->getSocketType()), $socket->isPersistent() ? $this->isType('string') : $this->isNull(), $this->isType('callable'))->will($this->returnCallback(function ($socketType, $persistentId, $callback) use($socket) { call_user_func($callback, $socket); return $socket; })); } return $context; }