UseCommand.php 777 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Pheanstalk\Command;
  3. use Pheanstalk\Contract\ResponseParserInterface;
  4. use Pheanstalk\Response\ArrayResponse;
  5. /**
  6. * The 'use' command.
  7. *
  8. * The "use" command is for producers. Subsequent put commands will put jobs into
  9. * the tube specified by this command. If no use command has been issued, jobs
  10. * will be put into the tube named "default".
  11. */
  12. class UseCommand extends TubeCommand implements ResponseParserInterface
  13. {
  14. public function getCommandLine(): string
  15. {
  16. return 'use '.$this->tube;
  17. }
  18. public function parseResponse(string $responseLine, ?string $responseData): ArrayResponse
  19. {
  20. return $this->createResponse('USING', [
  21. 'tube' => preg_replace('#^USING (.+)$#', '$1', $responseLine),
  22. ]);
  23. }
  24. }