Parse the key.

@param Key $key

@return ParsedKey
495152
public function parse(Key $key)
    {
        try {
            $resource = $key->getResource();
        } catch (KeyFormatException $e) {
            throw new KeyParsingException('Fail to load resource for key', 0, $e);
        }

        $rawData = openssl_pkey_get_details($resource);
        openssl_free_key($resource);

        if (!\is_array($rawData)) {
            throw new KeyParsingException(sprintf('Fail to parse key with error: %s', openssl_error_string()));
        }

        foreach (['type', 'key', 'bits'] as $requiredKey) {
            if (!isset($rawData[$requiredKey])) {
                throw new KeyParsingException(sprintf('Missing expected key "%s" in OpenSSL key', $requiredKey));
            }
        }

        $details = [];

        if (OPENSSL_KEYTYPE_RSA === $rawData['type']) {
            $details = $rawData['rsa'];
        } elseif (OPENSSL_KEYTYPE_DSA === $rawData['type']) {
            $details = $rawData['dsa'];
        } elseif (OPENSSL_KEYTYPE_DH === $rawData['type']) {
            $details = $rawData['dh'];
        } elseif (OPENSSL_KEYTYPE_EC === $rawData['type']) {
            $details = $rawData['ec'];
        }

        return new ParsedKey($key, $rawData['key'], $rawData['bits'], $rawData['type'], $details);
    }
149765
protected function parseNamespacedSegments($key)
    {
        list($namespace, $item) = explode('::', $key);

        // If the namespace is registered as a package, we will just assume the group
        // is equal to the namespace since all packages cascade in this way having
        // a single file per package, otherwise we'll just parse them as normal.
        if (array_key_exists($namespace, $this->packages)) {
            return $this->parsePackageSegments($key, $namespace, $item);
        }

        return parent::parseNamespacedSegments($key);
    }
347567
public function setKey($key)
    {
        $arr = $this->parseKey($key);
        $this->key = $arr['key'];
        $this->identifier = $arr['identifier'];
        $this->prefix = $arr['prefix'];

        return $this;
    }
121497
protected function getNested(string $key)
    {
        $parts = explode('.', $key);
        $result = $this->settings[$parts[0]];

        for ($i = 1; $i < count($parts); ++$i) {
            $value = $parts[$i];

            if (is_array($result) && array_key_exists($value, $result)) {
                $result = $result[$value];
                continue;
            }

            $result = null;
            break;
        }

        return $result;
    }
966702
private function parseKey($data, $key)
    {
        if (isset($data[$key])) {
            $value = (int) $data[$key];
            $this->scoreTiers []= new ScoreTier($key, $value);
            return $value;
        }

        throw new InvalidDataException();
    }
771278
protected function parseNamespacedSegments($key)
    {
        [$namespace, $item] = explode('::', $key);

        // First we'll just explode the first segment to get the namespace and group
        // since the item should be in the remaining segments. Once we have these
        // two pieces of data we can proceed with parsing out the item's value.
        $itemSegments = explode('.', $item);

        $groupAndItem = array_slice(
            $this->parseBasicSegments($itemSegments), 1
        );

        return array_merge([$namespace], $groupAndItem);
    }
527344
protected function processKey($key)
    {
        $key = trim(strtolower($key));
        $key = preg_replace('#[^a-z0-9\.]#', '-', $key) . '~' . $this->keySuffix;

        return $key;
    }
43150
private function parseName($key=null)
	{
		$name = $this->get('name');
		if ($name)
		{
			$firstname  = "";
			$middlename = "";
			$lastname   = "";

			$words = array_map('trim', explode(' ', $this->get('name')));
			$count = count($words);

			if ($count == 1)
			{
				$firstname = $words[0];
			}
			else if ($count == 2)
			{
				$firstname = $words[0];
				$lastname  = $words[1];
			}
			else if ($count == 3)
			{
				$firstname  = $words[0];
				$middlename = $words[1];
				$lastname   = $words[2];
			}
			else
			{
				$firstname  = $words[0];
				$lastname   = $words[$count-1];
				$middlename = $words[1];

				for ($i = 2; $i < $count-1; $i++)
				{
					$middlename .= ' ' . $words[$i];
				}
			}
			switch ($key)
			{
				case 'givenName':
					return trim($firstname);
					break;
				case 'middleName':
					return trim($middlename);
					break;
				case 'surname':
					return trim($lastname);
					break;
				default:
					return '';
			}
		}
	}
258843
protected function &_getKey($key)
    {
        $default = null;
        $parts = is_string($key) ? explode('.', $key) : $key;

        switch (count($parts)) {
            case 1:
                if (isset($this->_info[$parts[0]])) {
                    return $this->_info[$parts[0]];
                }

                return $default;
            case 2:
                if (isset($this->_info[$parts[0]][$parts[1]])) {
                    return $this->_info[$parts[0]][$parts[1]];
                }

                return $default;
            case 3:
                if (isset($this->_info[$parts[0]][$parts[1]][$parts[2]])) {
                    return $this->_info[$parts[0]][$parts[1]][$parts[2]];
                }

                return $default;
            case 4:
                if (isset($this->_info[$parts[0]][$parts[1]][$parts[2]][$parts[3]])) {
                    return $this->_info[$parts[0]][$parts[1]][$parts[2]][$parts[3]];
                }

                return $default;
            default:
                $data = $this->_info;
                foreach ($parts as $key) {
                    if (is_array($data) && isset($data[$key])) {
                        $data = $data[$key];
                    } else {
                        return $default;
                    }
                }
        }

        return $data;
    }
399427
public function setKey($key) {
        if(!$this->setModified('key', $key)->isModified()) {
            return $this;
        }
		$this->key = $key;
		return $this;
    }
752032
protected function _normalizeKey($key)
    {
        try {
            return $this->_normalizeString($key);
        } catch (InvalidArgumentException $e) {
            throw $this->_createOutOfRangeException($this->__('Invalid key'), null, $e, $key);
        }
    }
873964
private function prepareKey($key)
    {
        if (!preg_match('/^[a-zA-Z0-9_-]+$/', $key)) {
            throw new InvalidArgumentException($key);
        }

        return $this->keyPrefix . strtr($key, '-', '_');
    }
1129704
private function parse($key,$mode){
		if ($mode){
			if (!$key) return array();
			$key=explode(",",$key);
			for ($i=0; $i < sizeof($key); $i++)
				$key[$i]=$this->parse($key[$i],false);
			return $key;
		}
		$key=explode("(",$key);
		$data=array("db_name"=>trim($key[0]), "name"=>trim($key[0]));
		if (sizeof($key)>1)
			$data["name"]=substr(trim($key[1]),0,-1);
		return $data;		
	}
1188336
protected function parseData(string $key) : array
    {
        if (file_exists($this->getPath($key))) {
            $rawData = json_decode(file_get_contents($this->getPath($key)), true);
            $parsedData = ['d' => unserialize($rawData['d']), 't' => $rawData['t']];
        } else {
            $parsedData = ['d' => null, 't' => 0];
        }

        if (time() > $parsedData['t']) {
            $this->delete($key);

            return ['d' => null, 't' => 0];
        }

        return $parsedData;
    }
498096
protected function parseKey($key)
    {
        if (substr_count($key, $this->getDelimiter()) != 4)
        {
            throw new InvalidKeyException('Invalid file key: '.$key);
        }
        
        $this->key = $key;
        
        list($storageName, $className, $fieldName, $depth, $hashExt) = explode($this->getDelimiter(), $key);
        
        if (false !== strpos($hashExt, '.'))
        {
            list($hash, $extension) = explode('.', $hashExt, 2);
        }
        else
        {
            $hash = $hashExt;
            $extension = '';
        }
        
        $this->storageName = $storageName;
        $this->className = $className;
        $this->fieldName = $fieldName;
        $this->depth = $depth;
        $this->hash = $hash;
        $this->extension = $extension;
        
        return $this;
    }
536267
public function normalize($key)
    {
        if (strlen($key) > $this->length) {
            $checksum = dechex(crc32($key));
            return substr($key, 0, $this->length - strlen($checksum)) . $checksum;
        }

        return $key;
    }
105719
public function parseToken($key = 'access_token')
    {
        if ( $token = $this->getToken() )
        {
            $token_array = json_decode($token, true);

            return $token_array[$key];
        }
    }