FilePath   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isAbsolute() 0 4 1
A __toString() 0 4 1
A fromString() 0 4 1
A fromParts() 0 6 1
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