Parse an array of namespaced segments.

@param  string  $key
@return array
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);
    }
1007052
protected function parse($key)
    {
        $values = $this->registry;
        $parts = explode(".", $key);
        foreach ($parts as $part) {
            if ($part === "") {
                return $values;
            }
            if (!is_array($values) || !array_key_exists($part, $values)) {
                return ;
            }
            $values = $values[$part];
        }

        return $values;
    }
702155
protected function splitNamespaceAndKey($key)
    {
        if (strpos($key, '::') !== false) {
            list($namespace, $key) = explode('::', $key, 2);

            return [$namespace, $key];
        }

        return ['', $key];
    }
669448
protected function parseKey($key) {
        $key = trim($key);
        $data = explode('.', $key);
        $group = trim($data[0]);
        if (1 == count($data)) {
            return [$group, null];
        }

        return [$group, $data[1]];
    }
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;
    }
133360
public function getQueryMapping($schemaKey = 'default')
    {
        /** @noinspection PhpUndefinedFieldInspection */
        /** @noinspection StaticInvocationViaThisInspection */
        $pathWithKey = $this->getSchemaMapping();
        if (!isset($pathWithKey[$schemaKey])) {
            return [];
        }

        $path = trim($pathWithKey[$schemaKey]);
        $contents = trim(file_get_contents($path));
        $result = json_decode($contents, true);
        if (!is_array($result)) {
            return [];
        }

        return $result;
    }
319142
protected function getCastAsParamaters($key)
    {
        $cast_params = $this->getCastParams();

        $paramaters = explode(':', array_get($cast_params, $key, ''));
        $parsed = $this->parseCastParamaters($paramaters);

        return $parsed;
    }
990720
public function parseKey($key)
    {
        $keys = explode('.', $key);

        $keys = [implode(".", array_slice($keys, 0, -1)), $keys[count($keys) - 1]];

        $key = (new Collection($keys))->map(function ($part) {
            return '`'.$part.'`';
        })->implode('.');

        return DB::raw($key);
    }
139684
protected function namespaceAndKey($key)
    {
        if ($this->hasNamespace($key)) {
            return explode($this->nsSeparator, $key, 2);
        }
        return ['default', $key];
    }
1278057
protected function fileUrlAndKey($key)
    {

        if (isset($this->keyUrlCache[$key])) {
            return $this->keyUrlCache[$key];
        }

        $parts = explode('.', $key);
        $url = $this->urlOrFail();
        $partCount = count($parts);

        if ($partCount <= $this->nestingLevel) {
            $minLength = $this->nestingLevel+1;
            $msg = "The key segments has to have a minimum count of $minLength (nesting level: $this->nestingLevel)";
            throw (new KeyLengthException($msg))->setMinSegments($minLength);
        }

        $subKey = [];

        for ($i=0; $i<$partCount; $i++) {


            if ($i < $this->nestingLevel) {
                $url = $url->append($parts[$i]);
                continue;
            }


            if ($i == $this->nestingLevel) {
                $url = $url->append($this->fileName($parts[$i]));
                continue;
            }

            $subKey[] = $parts[$i];
        }

        $this->keyUrlCache[$key] = [$url, implode('.', $subKey)];

        return $this->keyUrlCache[$key];

    }
824543
public function parseKey($key)
    {
        // If we've already parsed the given key, we'll return the cached version we
        // already have, as this will save us some processing. We cache off every
        // key we parse so we can quickly return it on all subsequent requests.
        if (isset($this->parsed[$key])) {
            return $this->parsed[$key];
        }

        // If the key does not contain a double colon, it means the key is not in a
        // namespace, and is just a regular configuration item. Namespaces are a
        // tool for organizing configuration items for things such as modules.
        if (strpos($key, '::') === false) {
            $segments = explode('.', $key);

            $parsed = $this->parseBasicSegments($segments);
        } else {
            $parsed = $this->parseNamespacedSegments($key);
        }

        // Once we have the parsed array of this key's elements, such as its groups
        // and namespace, we will cache each array inside a simple list that has
        // the key and the parsed array for quick look-ups for later requests.
        return $this->parsed[$key] = $parsed;
    }
338644
public function offsetGet($key)
    {
        $key = "$key";
        if (array_key_exists($key, $this->data)) {
            return $this->data[$key];
        }

        return [];
    }
363876
public static function splitKey($key)
    {
        if (strpos($key, self::FIELD_KEY_SEPARATOR) === false) {
            return null;
        }
        list($sub, $fieldId) = explode(self::FIELD_KEY_SEPARATOR, $key, 2);

        return array('sub' => $sub, 'gtf_id_field' => $fieldId);
    }
1271234
private function splitToLast($key)
    {
        $split = explode($this->delimiter, $key);
        $key = implode($this->delimiter, array_slice($split, 0, -1));
        $last = end($split);

        return [$key, $last];
    }
5233
public function paramsFor(string $key): array
    {
        $params = [];
        if (isset($this->params[$key])) {
            $params = $this->params[$key];
        }

        return $params;
    }
936425
protected function parseCustomSegments(array $segments)
    {
        if (\count($segments) >= 2) {
            $group = "{$segments[0]}/{$segments[1]}";

            if ($this->getLoader()->exists($group)) {
                return [null, $group, \implode('.', \array_slice($segments, 2))];
            }
        }

        return $this->parseBasicSegments($segments);
    }
725540
public function getAsArray($key)
    {
        if (! $this->has($key)) {
            return [];
        }
        $res = $this->attributes[$key];
        if (is_null($res)) {
            return [null];
        }

        return (array) $res;
    }