Issues (222)

src/Parser/CodebaseDirectory.php (2 issues)

Labels
Severity
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 SplFileInfo;
9
use Webmozart\Assert\Assert;
0 ignored issues
show
The type Webmozart\Assert\Assert 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
final class CodebaseDirectory
12
{
13
    private readonly string $directory;
14
15 40
    public function __construct(string $path)
16
    {
17 40
        $this->directory = $this->getAbsolutePath($path);
0 ignored issues
show
The property directory is declared read-only in PhUml\Parser\CodebaseDirectory.
Loading history...
18
    }
19
20 26
    public function absolutePath(): string
21
    {
22 26
        return $this->directory;
23
    }
24
25 40
    private function getAbsolutePath(string $path): string
26
    {
27 40
        Assert::stringNotEmpty(
28
            $path,
29
            'The directory with the code to be scanned cannot be empty'
30
        );
31 40
        $directory = new SplFileInfo($path);
32 40
        if (! $directory->isDir()) {
33 4
            throw InvalidDirectory::notFoundAt($directory);
34
        }
35 36
        return $directory->getRealPath();
36
    }
37
}
38