FilesFinder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findProjectFiles() 0 9 1
A findChangedProjectFiles() 0 4 1
A filterFiles() 0 11 3
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