Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | public function parse($path) { |
||
34 | $path = trim($path, '/'); |
||
35 | $root = Config::get('directories.src'); |
||
36 | $files = Finder::create()->files()->in("{$root}/data/{$path}")->name('*.*')->sort(function(SplFileInfo $a, SplFileInfo $b) { |
||
37 | return strcmp($b->getRelativePath(), $a->getRelativePath()); |
||
38 | }); |
||
39 | $data = []; |
||
40 | |||
41 | foreach ($files as $file) { |
||
42 | $parser = $this->parserFactory->getParser($file->getFilename()); |
||
43 | |||
44 | $id = str_replace(".{$file->getExtension()}", '', $file->getFilename()); |
||
45 | |||
46 | $data[$id] = [ |
||
47 | 'id' => $id, |
||
48 | 'content' => $parser->parse($file->getRelativePathname()), |
||
49 | ]; |
||
50 | } |
||
51 | |||
52 | return $data; |
||
53 | } |
||
54 | } |
||
55 |