Parse an array of namespaced segments.

@param string $key

@return array
505027
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 (in_array($namespace, $this->packages)) {
            return $this->parsePackageSegments($key, $namespace, $item);
        }

        // Next 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);
    }
17918
private static function getNamespace(int $key, array $tokens): ?string
    {
        $namespace  = null;
        $tokenCount = \count($tokens);

        for ($i = $key; $i < $tokenCount; $i++) {
            if (self::isPartOfNamespace($tokens[$i])) {
                $namespace .= $tokens[$i][1];
            } elseif ($tokens[$i] === ';') {
                return $namespace;
            }
        }

        return null;
    }
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);
    }
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;
    }
733098
protected function parsePackageSegments($key, $namespace, $item)
    {
        $itemSegments = explode('.', $item);

        // If the configuration file doesn't exist for the given package group we can
        // assume that we should implicitly use the config file matching the name
        // of the namespace. Generally packages should use one type or another.
        if (! $this->getLoader()->exists($itemSegments[0], $namespace)) {
            return [$namespace, 'config', $item];
        }

        return parent::parseNamespacedSegments($key);
    }
932913
public function files(string $key): array
    {
        if (array_key_exists($key, $this->files)) {
            return $this->files[$key];
        }

        return [];
    }
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;
    }
100932
protected function parseStatementPrice($key)
    {
        $results = [];
        if (preg_match('/:' . $key . ':([CD])?.*[A-Z]{3}([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
            && !empty($results[2])
        ) {
            $sanitizedPrice = $this->sanitizePrice($results[2]);

            return (!empty($results[1]) && $results[1] === 'D') ? -$sanitizedPrice : $sanitizedPrice;
        }

        return '';
    }
1260097
public function parseKey($key)
	{
		$segments = parent::parseKey($key);

		if (is_null($segments[0])) $segments[0] = '*';

		return $segments;
	}
1071356
public static List<PathElement> parse( String key )  {

        if ( key.contains(AT) ) {
            return Arrays.<PathElement>asList( new AtPathElement( key ) );
        }
        else if ( STAR.equals(key) ) {
            return Arrays.<PathElement>asList( new StarAllPathElement( key ) );
        }
        else if ( key.contains(STAR) ) {
            if ( StringTools.countMatches(key, STAR) == 1 ) {
                return Arrays.<PathElement>asList( new StarSinglePathElement( key ) );
            }
            else {
                return Arrays.<PathElement>asList( new StarRegexPathElement( key ) );
            }
        }
        else {
            return Arrays.<PathElement>asList( new LiteralPathElement( key ) );
        }
    }
348802
private function parseRaw($key)
    {
        $key = str_replace('[]', '', $key);
        parse_str($key, $levels);
        if (is_null($levels)) {
            return null;
        }
        $inputs = $this->data;
        return $this->recurseGet($levels, $inputs);
    }
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;		
	}
686017
private static function ParseStructuredValue($Text, $Key)
	{
		$Text = array_map('trim', explode(';', $Text));

		$Result = array();
		$Ctr = 0;

		foreach (self::$Spec_StructuredElements[$Key] as $Index => $StructurePart)
		{
			$Result[$StructurePart] = isset($Text[$Index]) ? $Text[$Index] : null;
		}
		return $Result;
	}
1172270
public function parseData($data, array $modes, $key = null)
    {
        $return = [];

        uksort($modes, function ($a, $b) {
            return substr_count($b, '.')-substr_count($a, '.');
        });

        if (Utility::isCollection($data)) {
            $parsed = $this->parseCollection($modes, $data, $return);
        } else {
            $parsed = $this->parseResource($modes, $data, $return);
        }

        if ($key !== null) {
            $return[$key] = $parsed;
        } else {
            if (in_array('sideload', $modes)) {
                throw new InvalidArgumentException('$key cannot be null when ' .
                                    'resources are transformed using sideload.');
            }

            $return = $parsed;
        }

        return $return;
    }
1028564
protected function parseNamespaceSegments(string $name): array
    {
        $segments = explode(static::NAMESPACE_DELIMITER, $name);
        if (count($segments) !== 2) {
            throw new \InvalidArgumentException("Template [{$name}] has an invalid name.");
        }
        if (! isset($this->paths[$segments[0]])) {
            throw new \InvalidArgumentException("No namespace defined for [{$segments[0]}].");
        }

        return $segments;
    }
94254
protected function parseSubkeys($key) {
        $k          = $key;
        $subkeys    = [];
        $quoteChars = ["'", '"'];                       // single and double quotes

        while (true) {
            $k = trim($k);

            foreach ($quoteChars as $char) {
                if (strpos($k, $char) === 0) {          // subkey starts with a quote char
                    $pos = strpos($k, $char, 1);        // find the ending quote char
                    if ($pos === false) throw new InvalidArgumentException('Invalid argument $key: '.$key);
                    $subkeys[] = substr($k, 1, $pos-1);
                    $k         = trim(substr($k, $pos+1));
                    if (!strlen($k))                    // last subkey or next char is a key separator
                        break 2;
                    if (strpos($k, '.') !== 0) throw new InvalidArgumentException('Invalid argument $key: '.$key);
                    $k = substr($k, 1);
                    continue 2;
                }
            }

            // key is not quoted
            $pos = strpos($k, '.');                     // find next key separator
            if ($pos === false) {
                $subkeys[] = $k;                        // last subkey
                break;
            }
            $subkeys[] = trim(substr($k, 0, $pos));
            $k         = substr($k, $pos+1);            // next subkey
        }
        return $subkeys;
    }
1147104
protected static function getTemplatesByKey($key)
    {
        $templates = [];
        $scheme = PhpSms::scheme();
        $config = PhpSms::config();
        foreach (array_keys($scheme) as $name) {
            if (isset($config[$name][$key])) {
                $templates[$name] = $config[$name][$key];
            }
        }

        return $templates;
    }