StackFormation\Preprocessor::parseRefInDoubleQuotedStrings PHP Метод

parseRefInDoubleQuotedStrings() защищенный Метод

protected parseRefInDoubleQuotedStrings ( $json )
    protected function parseRefInDoubleQuotedStrings($json)
    {
        $json = preg_replace_callback('/"([^"]*){Ref:(.+?)}([^"]*)"/', function ($matches) {
            $snippet = $matches[0];
            $snippet = trim($snippet, '"');
            $pieces = preg_split('/({Ref:.+})/U', $snippet, -1, PREG_SPLIT_DELIM_CAPTURE);
            $processedPieces = [];
            foreach ($pieces as $piece) {
                if (empty($piece)) {
                    continue;
                }
                if (substr($piece, 0, 5) == '{Ref:') {
                    $processedPieces[] = preg_replace('/{Ref:(.+)}/', '{"Ref":"$1"}', $piece);
                } else {
                    $processedPieces[] = '"' . $piece . '"';
                }
            }
            return '{"Fn::Join": ["", [' . implode(', ', $processedPieces) . ']]}';
        }, $json);
        return $json;
    }