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

OutputPath::isEmpty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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