Completed
Push — master ( 9a7b87...ad20a3 )
by Alessandro
03:07
created

OutputFile::getFilePath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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