PhpCsFixer\Test\IntegrationCaseFactory::parseJson PHP Method

parseJson() private method

private parseJson ( string | null $encoded, array $template = null ) : array
$encoded string | null
$template array
return array
    private function parseJson($encoded, array $template = null)
    {
        // content is optional if template is provided
        if (!$encoded && null !== $template) {
            $decoded = array();
        } else {
            $decoded = json_decode($encoded, true);
            if (JSON_ERROR_NONE !== json_last_error()) {
                throw new \InvalidArgumentException(sprintf('Malformed JSON: "%s".', $encoded));
            }
        }
        if (null !== $template) {
            $decoded = array_merge($template, array_intersect_key($decoded, array_flip(array_keys($template))));
        }
        return $decoded;
    }