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

MarkdownParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 25
loc 25
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 16 16 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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