/** * @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; }
/** * @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); } }
/** * @param string $command * @param array $arguments * @return Response */ private function executeCommand($command, $arguments = []) { return $this->server->dispatchCommand($this->commandFactory->create($command, $arguments))->invoke(); }
/** * @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)); }
/** * @param CommandInterface $command * @param Server $server * @return JobOath */ public function createFromCommand(CommandInterface $command, Server $server) { return new JobOath($server->dispatchCommand($command), $this); }
/** * @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); }