original_string: public function attachCallback($callback, $type = self::TASK_COMPLETE)
      {
          if (!is_callable($callback)) {
              throw new Exception('Invalid callback specified');
          }
  
          if (!in_array(
              $type,
              array(self::TASK_COMPLETE, self::TASK_FAIL, self::TASK_STATUS)
          )) {
              throw new Exception('Invalid callback type specified');
          }
  
          $this->callback[$type][] = $callback;
  
          return $this;
      }
code: public function attachCallback($callback, $type = self::TASK_COMPLETE)
      {
          if (!is_callable($callback)) {
              throw new Exception('Invalid callback specified');
          }
  
          if (!in_array(
              $type,
              array(self::TASK_COMPLETE, self::TASK_FAIL, self::TASK_STATUS)
          )) {
              throw new Exception('Invalid callback type specified');
          }
  
          $this->callback[$type][] = $callback;
  
          return $this;
      }
code_tokens: public function attachCallback ( $ callback , $ type = self :: TASK_COMPLETE ) { if ( ! is_callable ( $ callback ) ) { throw new Exception ( 'Invalid callback specified' ) ; } if ( ! in_array ( $ type , array ( self :: TASK_COMPLETE , self :: TASK_FAIL , self :: TASK_STATUS ) ) ) { throw new Exception ( 'Invalid callback type specified' ) ; } $ this -> callback [ $ type ] [ ] = $ callback ; return $ this ; }
docstring: Attach a callback to this task.
  
  @param callback $callback A valid PHP callback
  @param int      $type     Type of callback
  
  @throws \MHlavac\Gearman\Exception When the callback is invalid.
  @throws \MHlavac\Gearman\Exception When the callback's type is invalid.
  
  @return $this
docstring_tokens: Attach a callback to this task .