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;
    }
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;
    }
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 ; }
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
Attach a callback to this task .