FilesFinder::findProjectFiles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Padawan\Framework\Generator;
4
5
use Padawan\Framework\Utils\PathResolver;
6
use Padawan\Domain\Project;
7
use Padawan\Domain\Generator\FilesFinder as FilesFinderInterface;
8
9
class FilesFinder implements FilesFinderInterface
10
{
11
    public function __construct(PathResolver $path)
12
    {
13
        $this->path = $path;
14
    }
15
16
    public function findProjectFiles(Project $project)
17
    {
18
        return $this->filterFiles(
19
            $project,
20
            $this->path->getDirFilesRecursive(
21
                $project->getRootDir()
22
            )
23
        );
24
    }
25
26
    public function findChangedProjectFiles(Project $project)
27
    {
28
        throw new \Exception("Not implemented yet");
29
    }
30
31
    protected function filterFiles(Project $project, $files)
32
    {
33
        $projectFiles = [];
34
        foreach ($files as $file) {
35
            if (!preg_match('/\.php$/', $file)) {
36
                continue;
37
            }
38
            $projectFiles[] = $this->path->relative($project->getRootDir(), $file);
39
        }
40
        return $projectFiles;
41
    }
42
    /** @var PathResolver */
43
    private $path;
44
}
45