解析一段字符串并生成key和value。
@param string $string
@return string|boolean 返回一个数组有两个字段，第一个为key，第二个为value。如果解析
失败则返回错误。
353896
private function _parseHADocField($string) {
    $separater = '=';
    $pos = strpos($string, $separater);

    if ($pos !== false) {
      $key = substr($string, 0, $pos);
      $value = substr($string, $pos + 1);
      return array($key, $value);
    } else {
      throw new Exception('The are no key and value in the field.');
    }
  }
151788
public function escape_string($string)
    {
        if (!$this->connection) {
            return $string;
        }

        if ($string === null) {
            return $string;
        }
        return $this->connection->escape_string($string);
    }
1074200
protected function encrypt($string)
    {
        $iv = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->cipherMode), MCRYPT_RAND);

        return mcrypt_encrypt($this->cipher, $this->secretKey, $string, $this->cipherMode, $iv);
    }
896957
static public function strToCamelCase($string)
	{
		$string = self::strToLowerUrl($string, false);

		$string = implode('', array_map('ucfirst', explode('_', $string)));
		$string = implode('', array_map('ucfirst', explode('-', $string)));

		return strtolower(substr($string, 0, 1)) . substr($string, 1);
	}
54483
public function hash($string)
	{
		// Format strength
		$strength = str_pad($this->strength, 2, '0', STR_PAD_LEFT);

		// Create salt
		$salt = $this->createSalt();

		//create prefix; $2y$ fixes blowfish weakness
		$prefix = PHP_VERSION_ID < 50307 ? '$2a$' : '$2y$';

		return crypt($string, $prefix.$strength.'$'.$salt.'$');
	}
873655
protected function parseString($string)
    {
        $array  = array();

        if (strlen($string) < 1) {
            return $array;
        }

        // Separate single string into an array of "key=value" strings
        $keyvalue = explode('&', $query_string);

        // Separate each "key=value" string into an array[key] = value
        foreach ($keyvalue as $pair) {
            list($k, $v) = explode('=', $pair, 2);

            // Handle the case where multiple values map to the same key
            // by pulling those values into an array themselves
            if (isset($query_array[$k])) {
                // If the existing value is a scalar, turn it into an array
                if (is_scalar($query_array[$k])) {
                    $query_array[$k] = array($query_array[$k]);
                }
                array_push($query_array[$k], $v);
            } else {
                $query_array[$k] = $v;
            }
        }

        return $array;
    }
808197
private function prepareString($string)
    {
        return str_replace(
            array_keys($this->owner->variables),
            array_values($this->owner->variables),
            $string
        );
    }
574178
public function convert(string $string): string
    {
        if ($this->encoding === null) {
            $this->encoding = $this->getEncoding($string);
        }

        if ($this->encoding === self::UTF16BE) {
            $string = mb_convert_encoding($string, "UTF-8", "UTF-16BE");
        }

        if ($this->encoding === self::UTF16LE) {
            $string = mb_convert_encoding($string, "UTF-8", "UTF-16LE");
        }

        return $string;
    }
1039959
public static function encode($string) 
	{
		$string = base64_encode($string);
		$string = rtrim($string, '=');
		$string = strtr($string, '+/', '-_');
		
		return $string;
	}
545595
public static function strToBool($string)
    {
        if(is_bool($string))
            return $string;

        if (in_array(strtolower((string)$string), array('1', 'true', 'on', '+', 'yes', 'y')))
            return true;
        elseif (in_array(strtolower((string)$string), array('', '0','false', 'off', '-', 'no', 'n')))
            return false;

        return false;
    }
927949
public static function ucFirst($string)
    {
        $ucFirst = static::sub($string, 0, 1);
        $ucFirst = static::upp($ucFirst);

        return $ucFirst . static::sub($string, 1);
    }
1360101
protected function encrypt(string $string)
    {
        $pub_key = openssl_pkey_get_public($this->getRsaKey($this->pub_key));

        $length = openssl_pkey_get_details($pub_key)['bits'];

        $string = str_split($string, $length / 8 - 11);
        $encryptedString = '';

        foreach ($string as $value) {
            openssl_public_encrypt($value, $encrypted, $pub_key);
            $encryptedString .= $encrypted;
        }

        return base64_encode($encryptedString);
    }
86180
public static function encode($string)
    {
        if (is_array($string)) {
            foreach ($string as $k => $substring) {
                $string[$k] = static::encode($substring);
            }
        } else {
            $string = urlencode($string);
        }

        return $string;
    }
435309
private static function unserializeValue( &$string ) {
		$error = null;
		set_error_handler( function ( $errno, $errstr ) use ( &$error ) {
			$error = $errstr;
			return true;
		} );
		$ret = unserialize( $string );
		restore_error_handler();

		if ( $error !== null ) {
			self::$logger->error( 'Value unserialization failed: ' . $error );
			return [ false, null ];
		}

		$serialized = serialize( $ret );
		$l = strlen( $serialized );
		if ( substr( $string, 0, $l ) !== $serialized ) {
			self::$logger->error(
				'Value unserialization failed: read value does not match original string'
			);
			return [ false, null ];
		}

		$string = substr( $string, $l );
		return [ true, $ret ];
	}
262130
public function encodeHashOfString($string)
    {

        $salt = $this->getServiceContainer()->getParameter('secret');

        $key = substr(base64_encode($salt), 0, 30);

        $options = array(
            'cost' => 13,
            'salt' => $key
        );

        $hash = hash('sha512', password_hash($string, PASSWORD_BCRYPT, $options));

        return $hash;
    }
966845
public static function stringToValue($string)
	{
		if($string == '')
		{
			return $string;
		}
		if(is_float($string))
		{
			return (float) $string;
		}
		if(is_int($string))
		{
			return (int) $string;
		}
		if(strtolower($string) == 'true')
		{
			return true;
		}
		if(strtolower($string) == 'false')
		{
			return false;
		}
		if(strtolower($string) == 'null')
		{
			return NULL;
		}
		
		return $string;
	}
1271726
public static function create($string): self
    {
        if ($string instanceof self) {
            return $string;
        }

        if (empty($string)) {
            throw new \InvalidArgumentException(
                    'Given string was null or empty, if you explicitly want to'
                    . ' create a Secret with value null use'
                    . ' Secret::forNull()'
            );
        }

        $self = new static();
        try {
            $encrypt = self::$encrypt;
            self::$store[$self->id] = ['payload' => $encrypt($string),
                                       'length'  => \iconv_strlen($string)
                                      ];
        } catch (\Throwable $t) {
            $t = null;
            // This intentionally catches *ALL* exceptions, in order not to fail
            // and produce a stacktrace containing arguments on the stack that
            // were supposed to be protected.
            unset(self::$store[$self->id]);
        }

        $string = str_repeat('*', strlen($string));
        $string = null;
        return $self;
    }