Test Failed
Push — master ( 5f8db2...b3d8d2 )
by Waaaaaaaaaa
02:26
created

Path::hasPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace Logfile\Traits;
4
5
trait Path
6
{
7
    protected $path = '';
8
9
    public function hasPath(): bool
10
    {
11
        return !empty($this->path);
12
    }
13
14
    public function getPath(): string
15
    {
16
        return $this->path;
17
    }
18
19
    public function setPath(string $path): void
20
    {
21
        $realpath = realpath($path);
22
23
        if (false === $realpath) {
24
            throw new \InvalidArgumentException('Path does not exist: '.$path);
25
        }
26
27
        $this->path = $realpath . '/';
28
    }
29
}
30