Completed
Push — master ( 216072...caf6f7 )
by Team eFabrica
02:21
created

FileFinder::find()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 4
nop 0
dl 0
loc 13
ccs 9
cts 9
cp 1
crap 3
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Efabrica\TranslationsAutomatization\FileFinder;
4
5
use Symfony\Component\Finder\Finder;
6
7
class FileFinder implements FileFinderInterface
8
{
9
    private $dirs = [];
10
11
    private $extensions = [];
12
13 6
    public function __construct(array $dirs, array $extensions)
14
    {
15 6
        $this->dirs = $dirs;
16 6
        $this->extensions = $extensions;
17 6
    }
18
19 6
    public function find(): array
20
    {
21 6
        $finder = Finder::create()->files();
22 6
        foreach ($this->extensions as $extension) {
23 6
            $finder->name("*.$extension");
24
        }
25 6
        $finder->in($this->dirs);
26
27 6
        $files = [];
28 6
        foreach ($finder as $file) {
29 6
            $files[] = (string) $file;
30
        }
31 6
        return $files;
32
    }
33
}
34