Passed
Push — master ( 0f9932...7bc3f9 )
by Brent
03:42
created

MarkdownParser::parse()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 10

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 4
nop 1
dl 16
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace brendt\stitcher\parser;
4
5
use Parsedown;
6
use Symfony\Component\Finder\Finder;
7
8 View Code Duplication
class MarkdownParser extends AbstractParser {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
10
    /**
11
     * @param string $path
12
     *
13
     * @return string
14
     */
15
    public function parse($path = '*.md') {
16
        $html = '';
17
        $finder = new Finder();
18
        if (!strpos($path, '.md')) {
19
            $path .= '.md';
20
        }
21
        $files = $finder->files()->in("{$this->root}")->path($path);
22
23
        foreach ($files as $file) {
24
            $html = Parsedown::instance()->parse($file->getContents());
25
26
            break;
27
        }
28
29
        return $html;
30
    }
31
32
}
33