public function enableCrypto($type, $clientOrServer = 'client', $enable = true)
    {
        if (!array_key_exists($type . '_' . $clientOrServer, $this->_encryptMethods)) {
            throw new InvalidArgumentException('Invalid encryption scheme chosen');
        }
        $method = $this->_encryptMethods[$type . '_' . $clientOrServer];

        // Prior to PHP 5.6.7 TLS_CLIENT was any version of TLS. This was changed in 5.6.7
        // to fix backwards compatibility issues, and now only resolves to TLS1.0
        //
        // See https://github.com/php/php-src/commit/10bc5fd4c4c8e1dd57bd911b086e9872a56300a0
        if (version_compare(PHP_VERSION, '5.6.7', '>=')) {
            if ($method == STREAM_CRYPTO_METHOD_TLS_CLIENT) {
                // @codingStandardsIgnoreStart
                $method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
                // @codingStandardsIgnoreEnd
            }
            if ($method == STREAM_CRYPTO_METHOD_TLS_SERVER) {
                // @codingStandardsIgnoreStart
                $method |= STREAM_CRYPTO_METHOD_TLSv1_1_SERVER | STREAM_CRYPTO_METHOD_TLSv1_2_SERVER;
                // @codingStandardsIgnoreEnd
            }
        }

        try {
            $enableCryptoResult = stream_socket_enable_crypto($this->connection, $enable, $method);
        } catch (Exception $e) {
            $this->setLastError(null, $e->getMessage());
            throw new SocketException($e->getMessage(), null, $e);
        }
        if ($enableCryptoResult === true) {
            $this->encrypted = $enable;

            return true;
        }
        $errorMessage = 'Unable to perform enableCrypto operation on the current socket';
        $this->setLastError(null, $errorMessage);
        throw new SocketException($errorMessage);
    }