text: <?php
  
  /**
   * The 'touch' command.
   *
   * The "touch" command allows a worker to request more time to work on a job.
   * This is useful for jobs that potentially take a long time, but you still want
   * the benefits of a TTR pulling a job away from an unresponsive worker.  A worker
   * may periodically tell the server that it's still alive and processing a job
   * (e.g. it may do this on DEADLINE_SOON).
   *
   * @author Paul Annesley
   * @package Pheanstalk
   * @licence http://www.opensource.org/licenses/mit-license.php
   */
  class Pheanstalk_Command_TouchCommand
  	extends Pheanstalk_Command_AbstractCommand
  	implements Pheanstalk_ResponseParser
  {
  	private $_job;
  
  	/**
  	 * @param Pheanstalk_Job $job
  	 */
  	public function __construct($job)
  	{
  		$this->_job = $job;
  	}
  
  	/* (non-phpdoc)
  	 * @see Pheanstalk_Command::getCommandLine()
  	 */
  	public function getCommandLine()
  	{
  		return sprintf('touch %d', $this->_job->getId());
  	}
  
  	/* (non-phpdoc)
  	 * @see Pheanstalk_ResponseParser::parseRespose()
  	 */
  	public function parseResponse($responseLine, $responseData)
  	{
  		if ($responseLine == Pheanstalk_Response::RESPONSE_NOT_FOUND)
  		{
  			throw new Pheanstalk_Exception_ServerException(sprintf(
  				'Job %d %s: does not exist or is not reserved by client',
  				$this->_job->getId(),
  				$responseLine
  			));
  		}
  
  		return $this->_createResponse($responseLine);
  	}
  }
  