Path::hasPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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