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

FileParser::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
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