SourceCodeFinder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 23
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A fromConfiguration() 0 7 2
A find() 0 8 2
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Parser;
7
8
use PhUml\Parser\Code\PhpCodeParser;
9
use Symfony\Component\Finder\Finder;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Finder\Finder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
/**
12
 * It inspects a directory finding all the files with PHP code and saves their contents
13
 *
14
 * This finder inspect inner directories recursively.
15
 * The contents of the files are used by the `PhpParser` to build a `Codebase`
16
 *
17
 * @see PhpCodeParser::parse()
18
 */
19
final class SourceCodeFinder implements CodeFinder
20
{
21 30
    public static function fromConfiguration(CodeFinderConfiguration $configuration): SourceCodeFinder
22
    {
23 30
        $finder = new Finder();
24 30
        if (! $configuration->recursive()) {
25 18
            $finder->depth(0);
26
        }
27 30
        return new self($finder);
28
    }
29
30 30
    private function __construct(private readonly Finder $finder)
31
    {
32
    }
33
34 26
    public function find(CodebaseDirectory $directory): SourceCode
35
    {
36 26
        $sourceCode = new SourceCode();
37 26
        $this->finder->in($directory->absolutePath())->files()->name('*.php')->sortByName();
38 26
        foreach ($this->finder as $file) {
39 25
            $sourceCode->add($file->getContents());
40
        }
41 26
        return $sourceCode;
42
    }
43
}
44