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

OutputFile::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 3
nc 2
nop 1
crap 12
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