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

OutputFile   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 37
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 3
A isEmpty() 0 4 1
A getFilePath() 0 8 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