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

FolderParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 17 2
1
<?php
2
3
namespace brendt\stitcher\parser;
4
5
use brendt\stitcher\factory\ParserFactory;
6
use Symfony\Component\Finder\Finder;
7
8
class FolderParser extends AbstractParser {
9
10
    /**
11
     * @param $path
12
     *
13
     * @return array
14
     */
15
    public function parse($path) {
16
        $data = [];
17
        $path = trim($path, '/');
18
        $finder = new Finder();
19
        $files = $finder->files()->in("{$this->root}/data/{$path}")->name('*.*');
20
        $factory = new ParserFactory();
21
22
        foreach ($files as $file) {
23
            $parser = $factory->getParser($file->getFilename());
24
25
            $id = str_replace(".{$file->getExtension()}", '', $file->getFilename());
26
27
            $data[$id] = $parser->parse($file->getRelativePathname());
28
        }
29
30
        return $data;
31
    }
32
}
33