Completed
Pull Request — master (#59)
by Alessandro
05:25
created

OutputFile::getFilePath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

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