OutputFile::getFilePath()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Paraunit\Configuration;
6
7
/**
8
 * Class OutputFile
9
 * @package Paraunit\Configuration
10
 */
11
class OutputFile
12
{
13
    /** @var string */
14
    private $filePath;
15
16
    /**
17
     * OutputPath constructor.
18
     * @param string $filePath
19
     */
20 19
    public function __construct($filePath)
21
    {
22 19
        if (is_string($filePath) && $filePath !== '') {
23 15
            $this->filePath = $filePath;
24
        }
25
    }
26
27 13
    public function isEmpty(): bool
28
    {
29 13
        return $this->filePath === null;
30
    }
31
32
    /**
33
     * @return string
34
     * @throws \RuntimeException
35
     */
36 13
    public function getFilePath(): string
37
    {
38 13
        if ($this->isEmpty()) {
39 3
            throw new \RuntimeException('Program requested an empty file path');
40
        }
41
42 10
        return $this->filePath;
43
    }
44
}
45