PhpOrient\Protocols\Binary\Serialization\CSV::eatMap PHP Method

eatMap() protected static method

Consume a map of keys to values.
protected static eatMap ( string $input ) : array
$input string The input to consume
return array The collected map and any remaining content.
    protected static function eatMap($input)
    {
        $map = [];
        $cluster = null;
        $input = ltrim($input, ' ');
        while (strlen($input)) {
            $c = $input[0];
            if ($c === ' ') {
                $input = ltrim(substr($input, 1), ' ');
                continue;
            } elseif ($c === ',') {
                $input = ltrim(substr($input, 1), ' ');
            } elseif ($c === '}') {
                $input = substr($input, 1);
                break;
            }
            $chunk = self::eatKey($input);
            $key = $chunk[0];
            $input = ltrim($chunk[1], ' ');
            if (strlen($input)) {
                $chunk = self::eatValue($input);
                $map[$key] = $chunk[0];
                $input = ltrim($chunk[1], ' ');
            } else {
                $map[$key] = null;
                break;
            }
        }
        return [$map, $input];
    }