Convert string formatted to array of Items.

@param string $data

@return Item[]
431691
public function formatToItems(string $data): array
    {
        return array_map(function (string $line) {
            $item = str_getcsv($line, ',');
            $itemAsArray = [
                'uuid' => [
                    'id' => $item[0],
                    'type' => $item[1],
                ],
                'metadata' => json_decode($item[2], true),
                'indexed_metadata' => json_decode($item[3], true),
                'searchable_metadata' => json_decode($item[4], true),
                'exact_matching_metadata' => json_decode($item[5], true),
                'suggest' => json_decode($item[6], true),
            ];

            if (!empty($item[7])) {
                $itemAsArray['coordinate'] = json_decode($item[7], true);
            }

            return Item::createFromArray($itemAsArray);
        }, str_getcsv($data, "\n"));
    }
471315
private function getRequestData(string $data) : array
    {
        if (preg_match_all('`\\&([^=]+)\\=`', '&' . $data, $matches)) {
            foreach (array_count_values($matches[1]) as $key => $count) {
                if ($count <= 1) {
                    continue;
                }
                if (stripos($key, '[') !== false) {
                    continue;
                }

                $data = str_replace('&' . $key . '=', '&' . $key . '[]=', $data);

                if (strpos($data, $key . '=') === 0) {
                    $data = $key . '[]' . substr($data, strpos($data, '='));
                }
            }
        }

        parse_str($data, $return);

        return is_array($return) ? $return : [];
    }
115820
protected function parseArray($data)
    {
        $pattern = '/(\[[^\[\]]*\])/';

        set_error_handler([__CLASS__, 'handleError']);

        while (true) {
            if (!preg_match($pattern, $data, $matches) > 0) {
                break;
            }

            $stringMatches = trim($matches[0]);

            $items = explode(',', $stringMatches);

            $currentData = $this->filterItems($items);


            $data = str_replace($stringMatches, serialize($currentData), $data);
        }

        $result = unserialize($data);

        restore_error_handler();

        return $result;
    }
1202281
private function formatCapabilities(array $data): array
    {
        $result = [];
        foreach ($data as $controller => $list) {
            $newList = [];
            foreach ($list as $type => $caps) {
                foreach ($caps as $cap) {
                    $field = $cap->getField();
                    $key = !empty($field) ? "${type}_(_${field}_)" : $type;
                    $newList[$key][] = $cap;
                }
            }
            $result[$controller] = $newList;
        }

        return $result;
    }
80889
public static function data_to_xml($data) {
        $xml = '';
        foreach ($data as $key => $val) {
            is_numeric($key) && $key = "item id=\"$key\"";
            $xml    .=  "<$key>";
            $xml    .=  ( is_array($val) || is_object($val)) ? self::data_to_xml($val)  : self::xmlSafeStr($val);
            list($key, ) = explode(' ', $key);
            $xml    .=  "</$key>";
        }
        return $xml;
    }
845606
private static function separate(array $data)
    {
        $array = [];

        foreach ($data as $provider) {

            if(($bool = self::isDelim($provider)) === false) {
                $array['required'][] = $provider;
            }
            else {
                if ($bool[1] === 'true') {
                    $array['required'][] = strval($bool[0]);
                } else {
                    $array['hidden'][] = strval($bool[0]);
                }
            }
        }

        return $array;

    }
1030045
protected function transform($data)
    {

        $items = [
            'name'       => $data[ 'name' ],
            'static'     => $this->boolValue($data[ '@attributes.static' ]),
            'line'       => (int)$data[ '@attributes.line' ],
            'visibility' => $data[ '@attributes.visibility' ],
            'namespace'  => $data[ '@attributes.namespace' ],
            'package'    => $data[ '@attributes.package' ],

            'description'      => $this->createDescription($data[ 'docblock.description' ]),
            'long-description' => $this->createDescription($data[ 'docblock.long-description' ]),
        ];

        $items[ 'full_name' ]  = $data->get('full_name', $this->belongsTo[ 'full_name' ] . '::' . Str::removeLeft($data[ 'name' ], '$'));
        $items[ 'class_name' ] = head(explode('::', $items[ 'full_name' ]));
        $items[ 'inherited' ]  = $this->belongsTo[ 'full_name' ] !== $items[ 'class_name' ];
        $items[ 'tags' ]       = $this->structures('docblock.tag', Tag::class, $data);

        $types = $data->get('docblock.tag.type', 'mixed');
        if ( !is_array($types) ) {
            $types = [ $types ];
        }
        $items[ 'types' ] = $types;

        return $items;
    }
1312033
protected function parseSet($data, $options)
    {
        if (empty($data)) {
            return [];
        }
        unset($options);
        $result = [];
        foreach ($data as $key => $val) {
            $item = $this->parseKey($key);
            if (is_array($val) && isset($val[0]) && in_array($val[0], ['$inc', '$set', '$unset', '$push', '$pushall', '$addtoset', '$pop', '$pull', '$pullall'])) {
                $result[$val[0]][$item] = $this->parseValue($val[1], $key);
            } else {
                $result['$set'][$item] = $this->parseValue($val, $key);
            }
        }
        return $result;
    }
54841
private function hydrateIfJsonToArray($data)
    {
        if (is_array($data)) {
            return $data;
        }
        elseif (is_string($data)) {
            $attempt = json_decode($data, true);
            return empty($attempt) ? $data : $attempt;
        }

        return [];
    }
218252
protected function recursiveConvertArray($data)
    {
        $out = [];

        foreach ($data as $key => $value) {
            $nkey = $this->normalize($key);

            if (in_array($nkey, $this->ignoredAttributes)) {
                continue;
            }

            $out[$nkey] = is_scalar($value) ? $value : $this->convertValue($value);
        }

        return $out;
    }
1185344
public static function extract($data)
    {
        $results = array();
        foreach ($data as $key => $value) {
            $key = strtoupper($key);
            if (strpos($key, 'X_') === 0 || strpos($key, 'HTTP_') === 0 || in_array($key, static::$special)) {
                if ($key === 'HTTP_CONTENT_LENGTH') {
                    continue;
                }
                $results[$key] = $value;
            }
        }

        return $results;
    }
895065
private function getPieces(string $data) : array
    {
        $pieces = \json_decode(\base64_decode($data), true);

        if ($pieces === false ||
            !isset($pieces['version'], $pieces['hmac'], $pieces['value'], $pieces['iv'], $pieces['keySalt'], $pieces['cipher'])
        ) {
            throw new EncryptionException('Data is not in correct format');
        }

        if (!in_array($pieces['cipher'], self::$approvedCiphers)) {
            throw new EncryptionException("Cipher \"{$pieces['ciper']}\" is not supported");
        }

        if (\mb_strlen(\base64_decode($pieces['iv']), '8bit') !== \openssl_cipher_iv_length($pieces['cipher'])) {
            throw new EncryptionException('IV is incorrect length');
        }

        if (\mb_strlen(\base64_decode($pieces['keySalt']), '8bit') !== IKeyDeriver::KEY_SALT_BYTE_LENGTH) {
            throw new EncryptionException('Key salt is incorrect length');
        }

        if (\mb_strlen($pieces['hmac'], '8bit') !== self::$hmacByteLength) {
            throw new EncryptionException('HMAC is incorrect length');
        }

        return $pieces;
    }
384311
protected function transform($data)
    {
        $items = $data->get('@attributes', [])->toArray();
        if ( isset($items[ 'line' ]) ) {
            $items[ 'line' ] = (int)$items[ 'line' ];
        }
        return $items;
    }
985337
protected function serializeItem($data) {
        if ($data instanceof IArrayable) {
            return $data->toArray();
        } else if ($data instanceof IJsonable) {
            return $data->toJson();
        } else if ($data instanceof IStringable) {
            return $data->toString();
        }

        return $data;
    }
1105283
protected function rename(array $data): array
    {
        $result = [];
        foreach ($data as $dataItem) {
            list($keyId, $dataTmp) = $this->getKeyValue($dataItem);

            if ($keyId === null) {
                $result[] = $dataTmp;
            } else {
                $result[$keyId] = $dataTmp;
            }
        }

        return $result;
    }
867467
protected function processProperties($data)
    {

        // Will hold the properties we are sending back
        $properties = [];

        // All of these are split on space
        $items = explode(' ', $data);

        // Iterate over the items
        foreach ($items as $item) {
            // Explode and make sure we always have 2 items in the array
            list($key, $value) = array_pad(explode('=', $item, 2), 2, '');

            // Convert spaces and other character changes
            $properties[$key] = utf8_encode(str_replace(
                [
                    '\\s', // Translate spaces
                ],
                [
                    ' ',
                ],
                $value
            ));
        }

        return $properties;
    }
1040750
protected function parseScalarResult($data)
    {
        if (\is_array($data)) {
            $data = reset($data);
        }

        return [
            'id' => (string) $data,
            'text' => (string) $data,
        ];
    }