Passed
Push — attribute-types ( 3de1eb )
by Luis
10:25
created

CodebaseDirectory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 7.4
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Parser;
9
10
use SplFileInfo;
11
use Webmozart\Assert\Assert;
0 ignored issues
show
Bug introduced by
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...
12
13
final class CodebaseDirectory
14
{
15
    private SplFileInfo $directory;
16
17
    public function __construct(string $path)
18
    {
19
        $this->setDirectory($path);
20
    }
21
22
    public function absolutePath(): string
23
    {
24
        return (string) $this->directory->getRealPath();
25
    }
26
27
    private function setDirectory(string $path): void
28
    {
29
        Assert::stringNotEmpty(
30
            $path,
31
            'The directory with the code to be scanned cannot be empty'
32
        );
33
        $directory = new SplFileInfo($path);
34
        if (! $directory->isDir()) {
35
            throw InvalidDirectory::notFoundAt($directory);
36
        }
37
        $this->directory = $directory;
38
    }
39
}
40