diff options
Diffstat (limited to 'intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php')
| -rw-r--r-- | intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php new file mode 100644 index 0000000..5483a1a --- /dev/null +++ b/intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php @@ -0,0 +1,62 @@ +<?php + +namespace Pheanstalk\Command; + +use Pheanstalk\Exception; +use Pheanstalk\Response; + +/** + * The 'pause-tube' command. + * Temporarily prevent jobs being reserved from the given tube. + * + * @author Paul Annesley + * @package Pheanstalk + * @license http://www.opensource.org/licenses/mit-license.php + */ +class PauseTubeCommand + extends AbstractCommand + implements \Pheanstalk\ResponseParser +{ + private $_tube; + private $_delay; + + /** + * @param string $tube The tube to pause + * @param int $delay Seconds before jobs may be reserved from this queue. + */ + public function __construct($tube, $delay) + { + $this->_tube = $tube; + $this->_delay = $delay; + } + + /* (non-phpdoc) + * @see Command::getCommandLine() + */ + public function getCommandLine() + { + return sprintf( + 'pause-tube %s %u', + $this->_tube, + $this->_delay + ); + } + + /* (non-phpdoc) + * @see ResponseParser::parseResponse() + */ + public function parseResponse($responseLine, $responseData) + { + if ($responseLine == Response::RESPONSE_NOT_FOUND) { + throw new Exception\ServerException(sprintf( + '%s: tube %s does not exist.', + $responseLine, + $this->_tube + )); + } elseif ($responseLine == Response::RESPONSE_PAUSED) { + return $this->_createResponse(Response::RESPONSE_PAUSED); + } else { + throw new Exception('Unhandled response: '.$responseLine); + } + } +} |
