Code Duplication    Length = 17-17 lines in 2 locations

src/TextFilter/CTextFilter.php 2 locations

@@ 325-341 (lines=17) @@
322
     *
323
     * @return array with the formatted text and the front matter.
324
     */
325
    public function jsonFrontMatter($text)
326
    {
327
        list($text, $frontmatter) = $this->extractFrontMatter($text, "{{{\n", "}}}\n");
328
329
        if (!empty($frontmatter)) {
330
            $frontmatter = json_decode($frontmatter, true);
331
332
            if (is_null($frontmatter)) {
333
                throw new Exception("Failed parsing JSON frontmatter.");
334
            }
335
        }
336
337
        return [
338
            "text" => $text,
339
            "frontmatter" => $frontmatter
340
        ];
341
    }
342
343
344
@@ 352-368 (lines=17) @@
349
     *
350
     * @return array with the formatted text and the front matter.
351
     */
352
    public function yamlFrontMatter($text)
353
    {
354
        list($text, $frontmatter) = $this->extractFrontMatter($text, "---\n", "...\n");
355
356
        if (function_exists("yaml_parse") && !empty($frontmatter)) {
357
            $frontmatter = yaml_parse("---\n$frontmatter...\n");
358
359
            if ($frontmatter === false) {
360
                throw new Exception("Failed parsing YAML frontmatter.");
361
            }
362
        }
363
364
        return [
365
            "text" => $text,
366
            "frontmatter" => $frontmatter
367
        ];
368
    }
369
370
371