YamlInline::parseSequence PHP Method

parseSequence() protected static method

Parse sequence to yaml
protected static parseSequence ( string $sequence, integer &$i ) : string
$sequence string
$i integer
return string YAML
    protected static function parseSequence($sequence, &$i = 0)
    {
        $output = array();
        $len = strlen($sequence);
        $i += 1;
        // [foo, bar, ...]
        while ($i < $len) {
            switch ($sequence[$i]) {
                case '[':
                    // nested sequence
                    $output[] = self::parseSequence($sequence, $i);
                    break;
                case '{':
                    // nested mapping
                    $output[] = self::parseMapping($sequence, $i);
                    break;
                case ']':
                    return $output;
                case ',':
                case ' ':
                    break;
                default:
                    $isQuoted = in_array($sequence[$i], array('"', "'"));
                    $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i);
                    if (!$isQuoted && false !== strpos($value, ': ')) {
                        // embedded mapping?
                        try {
                            $value = self::parseMapping('{' . $value . '}');
                        } catch (InvalidArgumentException $e) {
                            // no, it's not
                        }
                    }
                    $output[] = $value;
                    --$i;
            }
            ++$i;
        }
        throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $sequence));
    }