Completed
Push — master ( dcd98f...8e1797 )
by Luis
07:11 queued 02:59
created

CodeFinder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A files() 0 3 1
A __construct() 0 4 1
A addDirectory() 0 8 3
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
namespace PhUml\Parser;
8
9
use Symfony\Component\Finder\Finder;
10
11
class CodeFinder
12
{
13
    /** @var Finder */
14
    private $finder;
15
16
    /** @var string[] */
17
    private $files;
18
19 36
    public function __construct(Finder $finder = null)
20
    {
21 36
        $this->finder = $finder ?? new Finder();
22 36
        $this->files = [];
23 36
    }
24
25
26 12
    public function addDirectory(string $directory, bool $recursive = true): void
27
    {
28 12
        if (!$recursive) {
29 6
            $this->finder->depth(0);
30
        }
31 12
        $this->finder->in($directory)->files()->name('*.php');
32 12
        foreach ($this->finder as $file) {
33 12
            $this->files[] = $file->getContents();
34
        }
35 12
    }
36
37
    /** @return string[] */
38 15
    public function files(): array
39
    {
40 15
        return $this->files;
41
    }
42
}
43