Completed
Push — master ( bf487d...84f230 )
by Alessandro
10:10
created

OutputFile   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
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 34
ccs 9
cts 9
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
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 12
    public function __construct($filePath)
20
    {
21 12
        if (is_string($filePath) && $filePath !== '') {
22 9
            $this->filePath = $filePath;
23
        }
24
    }
25
26 8
    public function isEmpty(): bool
27
    {
28 8
        return $this->filePath === null;
29
    }
30
31
    /**
32
     * @return string
33
     * @throws \RuntimeException
34
     */
35 8
    public function getFilePath(): string
36
    {
37 8
        if ($this->isEmpty()) {
38 3
            throw new \RuntimeException('Program requested an empty file path');
39
        }
40
41 5
        return $this->filePath;
42
    }
43
}
44