public function setResultMode($mode)
    {
        if( !is_int($mode) || $mode < 0 || $mode > 3 ) {
            throw new InvalidArgumentException("Invalid result mode");
        }
        $this->resultMode = $mode;
        return $this;
    }