diff options
| author | horus_arch | 2017-02-20 12:42:43 +0100 |
|---|---|---|
| committer | horus_arch | 2017-02-20 12:42:43 +0100 |
| commit | 95c15758b50144105064d2613d1e9a9da23d4e7c (patch) | |
| tree | 373eea2812fa4a7c6f58c16528e2875a208b1ada /intern.gospeladlershof.de/vendor/pda/pheanstalk/src/Command/PauseTubeCommand.php | |
| parent | 3702922f4ab7f3d73f802b94d8b36571c589cb2c (diff) | |
| download | gospeladlershof.de-95c15758b50144105064d2613d1e9a9da23d4e7c.tar.gz | |
Committed vendor/ for lazyness.
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); + } + } +} |
