Set the cipher mode

@param  string                             $mode
@throws Exception\InvalidArgumentException
@return Mcrypt
515850
public function setMode($mode) {
        if (!empty($mode)) {
            $mode = strtolower($mode);
            if (!array_key_exists($mode, $this->supportedModes)) {
                throw new \Cityware\Exception\InvalidArgumentException(
                "The mode $mode is not supported by " . __CLASS__
                );
            }
            $this->mode = $mode;
        }

        return $this;
    }
987649
public static function validate(string $mode)
    {
        if (!self::isValid($mode)) {
            throw InvalidArgumentException::format(
                    'Invalid foreign key mode: expecting one of (%s), %s given',
                    Debug::formatValues(self::$modes), $mode
            );
        }
    }
292394
public function setIterationMode($mode) {
		switch ($mode) {
			case self::ITERATION_STRAIGHT:
				$this->_map = array_keys($this->_data);
				break;
			
			case self::ITERATION_REVERSE:
				$this->_map = array_reverse(array_keys($this->_data));
				break;
			
			case self::ITERATION_EVEN:
				$this->_map = [];
				
				foreach (array_keys($this->_data) as $key => $value) {
					if ($key % 2 === 0) {
						$this->_map[] = $value;
					}
				}
				break;
				
			case self::ITERATION_ODD:
				$this->_map = [];
				
				foreach (array_keys($this->_data) as $key => $value) {
					if ($key % 2 !== 0) {
						$this->_map[] = $value;
					}
				}
				break;
		}
		
		return $this;
	}
1098809
public function setGroupDisplayMode($mode)
    {
        if (!is_string($mode)) {
            throw new InvalidArgumentException(
                'Display mode must be a string'
            );
        }

        if ($mode === 'tabs') {
            $mode = 'tab';
        }

        $this->groupDisplayMode = $mode;

        return $this;
    }
164697
public function setAuthMode($mode)
    {
        if (!class_exists($mode)) {
            throw new \Exception(sprintf(
                "Class %s doesn't exists",
                $mode
            ));
        }

        $this->authMode = $mode;

        $authClass = is_string($mode) ? new $mode() : $mode;
        if (!$authClass instanceof SecurityInterface) {
            throw new \Exception(sprintf(
                'Auth mode must be intstance of %s',
                SecurityInterface::class
            ));
            exit;
        }

        $this->security = $authClass;
        $this->authMode = get_class($this->security);

        if ($this->authDir) {
            $this->security->setPath($this->authDir);
        }
    }
991062
public static function setMode($mode = '')
    {
        static::$MODE = 0;
        if (empty($mode)) {
            return;
        }
        $mode = explode(',', $mode);
        foreach ($mode as $m) {
            static::$MODE |= constant('static::SQL_MODE_' . $m);
        }
    }
310209
function _crypt($text, $mode)
    {
        if ( CRYPT_RC4_MODE == CRYPT_RC4_MODE_MCRYPT ) {
            $keyStream = $mode == CRYPT_RC4_ENCRYPT ? 'encryptStream' : 'decryptStream';

            if ($this->$keyStream === false) {
                $this->$keyStream = mcrypt_module_open($this->mode, '', MCRYPT_MODE_STREAM, '');
                mcrypt_generic_init($this->$keyStream, $this->key, '');
            } else if (!$this->continuousBuffer) {
                mcrypt_generic_init($this->$keyStream, $this->key, '');
            }
            $newText = mcrypt_generic($this->$keyStream, $text);
            if (!$this->continuousBuffer) {
                mcrypt_generic_deinit($this->$keyStream);
            }

            return $newText;
        }

        if ($this->encryptStream === false) {
            $this->setKey($this->key);
        }

        switch ($mode) {
            case CRYPT_RC4_ENCRYPT:
                $keyStream = $this->encryptStream;
                list($i, $j) = $this->encryptIndex;
                break;
            case CRYPT_RC4_DECRYPT:
                $keyStream = $this->decryptStream;
                list($i, $j) = $this->decryptIndex;
        }

        $newText = '';
        for ($k = 0; $k < strlen($text); $k++) {
            $i = ($i + 1) & 255;
            $j = ($j + $keyStream[$i]) & 255;
            $temp = $keyStream[$i];
            $keyStream[$i] = $keyStream[$j];
            $keyStream[$j] = $temp;
            $temp = $keyStream[($keyStream[$i] + $keyStream[$j]) & 255];
            $newText.= chr(ord($text[$k]) ^ $temp);
        }

        if ($this->continuousBuffer) {
            switch ($mode) {
                case CRYPT_RC4_ENCRYPT:
                    $this->encryptStream = $keyStream;
                    $this->encryptIndex = array($i, $j);
                    break;
                case CRYPT_RC4_DECRYPT:
                    $this->decryptStream = $keyStream;
                    $this->decryptIndex = array($i, $j);
            }
        }

        return $newText;
    }
193444
protected function setMode($mode)
    {
        $mode = strtolower($mode);
        if (!in_array($mode, self::$modes)) {
            throw new InvalidArgumentException(sprintf('Invalid binary mode: %s', $mode));
        }
        $this->options['mode'] = $mode;
    }
1296
public function setDialect($dialect)
    {
        if (!Type::isStringLike($dialect)) {
            throw new InvalidArgumentException('Dialect hast to be stringlike, not ' . Type::of($dialect));
        }
        $this->dialect = $dialect;
        return $this;
    }
221754
private static function _createIV($cipher, $mode) {
        $size = self::_getIVSize($cipher, $mode);
        return mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
    }
1267570
public function setToleranceMode($toleranceMode)
    {
        if (in_array($toleranceMode, ToleranceMode::asArray(), true)) {
            $this->toleranceMode = $toleranceMode;
        } else {
            $msg = "The toleranceMode argument must be a value from the ToleranceMode enumeration, '" . $toleranceMode . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
721823
public function encrypt($data)
    {
        $this->checkClosed();

        $data = self::convertToString($data);

        if (strlen($data) == 0) {
            throw new \InvalidArgumentException('Encryption doesn\'t support empty string');
        }

        //Encryption
        if ($this->randomInitializationVector) {
            $initializationVector = mcrypt_create_iv($this->initializationVectorSize, $this->mcryptRandomMethod);
        } else {
            $initializationVector = $this->fixedInitializationVector;
        }
        mcrypt_generic_init($this->module, $this->key, $initializationVector);
        $encryptedData = mcrypt_generic($this->module, (string) $data);
        if ($this->randomInitializationVector) {
            $encryptedData = $initializationVector . $encryptedData;
        }

        //Base64
        if ($this->base64) {
            $encryptedData = base64_encode($encryptedData);

            //Url safe
            if ($this->base64UrlSafe) {
                $encryptedData = strtr($encryptedData, self::$BASE64_URL_SAFE_REPLACE[0], self::$BASE64_URL_SAFE_REPLACE[1]);
            }

            $encryptedData = rtrim($encryptedData, '='); //Remove '=' at the end (it's useless)
        }

        return $encryptedData;
    }
1293239
public function setCommand($command)
    {
        if (!preg_match(self::$_regex['command'], $command)) {
            throw new \InvalidArgumentException(sprintf('Command "%s" is incorect', $command));
        }

        $this->command = $command;

        return $this->generateHash();
    }
917538
public function setUnserializeMode($unserializeMode)
    {
        switch ($unserializeMode) {
            case self::STRICT_MODE:
            case self::MEDIUM_STRICT_MODE:
            case self::NON_STRICT_MODE:
                $this->unserializeMode = $unserializeMode;
                break;
            default:
                throw new InvalidArgumentException(sprintf('Non acceptable unserialize mode: "%s"', $unserializeMode));
        }

        return $this;
    }
209732
public function setCommand($command)
    {
        if (!is_string($command)) {
            throw new InvalidArgumentException('string', 0);
        }
        // escape command
        $this->command = ($this->flags & ESCAPE) ? escapeshellcmd($command) : $command;

        return $this;
    }
48106
public function setEncryption(string $encryption): self
    {
        $encryption = strtolower($encryption);
        if ('tls' === $encryption) {
            $this->protocol = 'tcp';
            $this->tls = true;
        } else {
            $this->protocol = $encryption;
            $this->tls = false;
        }

        return $this;
    }
557009
public function setFetchMode($mode)
    {
        $this->_fetchMode = $mode;
        try {
            return $this->_stmt->setFetchMode($mode);
        } catch (PDOException $e) {
            // require_once 'Zend/Db/Statement/Exception.php';
            throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
        }
    }