original_string: 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);
      }
code: 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);
      }
code_tokens: 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 ) ; }
docstring: Encrypts current stream socket, using one of the defined encryption methods
  
  @param string $type can be one of 'ssl2', 'ssl3', 'ssl23' or 'tls'
  @param string $clientOrServer can be one of 'client', 'server'. Default is 'client'
  @param bool $enable enable or disable encryption. Default is true (enable)
  @return bool True on success
  @throws \InvalidArgumentException When an invalid encryption scheme is chosen.
  @throws \Cake\Network\Exception\SocketException When attempting to enable SSL/TLS fails
  @see stream_socket_enable_crypto
docstring_tokens: Encrypts current stream socket using one of the defined encryption methods