FilePath::isAbsolute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Phpactor\ClassFileConverter\Domain;
4
5
use Webmozart\PathUtil\Path;
6
7
final class FilePath
8
{
9
    private $path;
10
11
    private function __construct(string $path)
12
    {
13
        $path = Path::canonicalize($path);
14
        $this->path = $path;
15
    }
16
17
    public function isAbsolute(): bool
18
    {
19
        return Path::isAbsolute($this->path);
20
    }
21
22
    public function __toString()
23
    {
24
        return $this->path;
25
    }
26
27
    public static function fromString($path): FilePath
28
    {
29
        return new self($path);
30
    }
31
32
    public static function fromParts(array $parts): FilePath
33
    {
34
        $path = implode('/', $parts);
35
36
        return new self($path);
37
    }
38
}
39