Test Failed
Push — master ( a58c94...1bcec0 )
by Brent
03:26
created

FileParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 11 2
1
<?php
2
3
namespace Brendt\Stitcher\Parser;
4
5
use Brendt\Stitcher\Config;
6
use Symfony\Component\Finder\Finder;
7
8
/**
9
 * The FileParser takes a path and reads the file contents from that path.
10
 */
11
class FileParser implements Parser {
12
13
    /**
14
     * @param $path
15
     *
16
     * @return string
17
     */
18
    public function parse($path) {
19
        $files = Finder::create()->files()->in(Config::get('directories.src'))->path(trim($path, '/'))->getIterator();
20
        $files->rewind();
21
        $file = $files->current();
22
23
        if (!$file) {
24
            return '';
25
        }
26
27
        return $file->getContents();
28
    }
29
30
}
31