Beispiel #1
0
 /**
  * @return Tube[]
  * @throws Exception\InvalidArgumentException
  */
 public function tubes()
 {
     $tubes = [];
     foreach ($this->server->dispatchCommand($this->commandFactory->create(CommandInterface::COMMAND_LIST_TUBES))->invoke()->getData() as $tubeName) {
         $tubes[] = new Tube($tubeName, $this->server);
     }
     return $tubes;
 }
Beispiel #2
0
 /**
  * @inheritDoc
  */
 protected function extractData($responseLine, Server $server)
 {
     list(, $dataLength) = explode(' ', $responseLine);
     $rawData = $server->readData($dataLength);
     try {
         return Yaml::parse($rawData);
     } catch (ParseException $exception) {
         throw Exception::wrap($exception);
     }
 }
Beispiel #3
0
 /**
  * @param string $command
  * @param array $arguments
  * @return Response
  */
 private function executeCommand($command, $arguments = [])
 {
     return $this->server->dispatchCommand($this->commandFactory->create($command, $arguments))->invoke();
 }
Beispiel #4
0
 /**
  * @return JobOath
  * @throws Exception\InvalidArgumentException
  */
 public function reserveOath()
 {
     return $this->jobFactory->createFromCommand($this->commandFactory->create(CommandInterface::COMMAND_RESERVE), $this->server->transformTubeStatusTo($this->getTubeStatus(), TubeStatus::TRANSFORM_WATCHED));
 }
Beispiel #5
0
 /**
  * @param CommandInterface $command
  * @param Server $server
  * @return JobOath
  */
 public function createFromCommand(CommandInterface $command, Server $server)
 {
     return new JobOath($server->dispatchCommand($command), $this);
 }
Beispiel #6
0
 /**
  * @expectedException \Beanie\Exception\SocketException
  * @expectedExceptionCode 123
  * @expectedExceptionMessage nope
  */
 public function testReadData_connectionDropped_throwsSocketException()
 {
     $this->_socketCreateSuccess();
     $this->_socketConnectSuccess();
     $this->_setSocketError(123, 'nope');
     $this->_getNativeFunctionMock()->expects($this->once())->method('socket_read')->willReturn(false);
     $server = new Server();
     $server->readData(321);
 }