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

OutputFile   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 34
ccs 0
cts 17
cp 0
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
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