File   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 30
ccs 9
cts 13
cp 0.6923
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 4
A getValue() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
namespace CompoLab\Domain\ValueObject;
4
5
final class File
6
{
7
    /** @var string */
8
    private $value;
9
10 7
    public function __construct(string $value)
11
    {
12 7
        if (!is_file($value)) {
13 2
            throw new \InvalidArgumentException(sprintf('Path "%s" is not a valid file', $value));
14
        }
15
16 5
        if (!is_readable($value)) {
17
            throw new \InvalidArgumentException(sprintf('File "%s" is not readable', $value));
18
        }
19
20 5
        if (!is_writable($value)) {
21
            throw new \InvalidArgumentException(sprintf('File "%s" is not writable', $value));
22
        }
23
24 5
        $this->value = realpath($value);
25 5
    }
26
27
    public function getValue(): string
28
    {
29
        return $this->value;
30
    }
31
32 4
    public function __toString()
33
    {
34 4
        return $this->value;
35
    }
36
}
37