Completed
Push — master ( 1b0b5c...c3ce6a )
by Sebastian
04:24
created

Status::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace phpbu\App\Backup\Source;
3
4
use phpbu\App\Exception;
5
6
/**
7
 * Status class.
8
 *
9
 * @package    phpbu
10
 * @subpackage Backup
11
 * @author     Sebastian Feldmann <[email protected]>
12
 * @copyright  Sebastian Feldmann <[email protected]>
13
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
14
 * @link       http://phpbu.de/
15
 * @since      Class available since Release 2.0.1
16
 */
17
class Status
18
{
19
    /**
20
     * Source handles compression by itself.
21
     *
22
     * @var boolean
23
     */
24
    private $handledCompression;
25
26
    /**
27
     * Path to generated source data.
28
     *
29
     * @var string
30
     */
31
    private $dataPath;
32
33
    /**
34
     * Constructor
35
     */
36 12
    public function __construct()
37
    {
38 12
        $this->handledCompression = true;
39 12
    }
40
41
    /**
42
     * Source doesn't handle compression.
43
     *
44
     * @param  string $path
45
     * @return \phpbu\App\Backup\Source\Status
46 8
     */
47
    public function uncompressed($path)
48 8
    {
49 8
        $this->handledCompression = false;
50
        $this->dataPath           = $path;
51
        return $this;
52
    }
53
54
    /**
55
     * Did the Source handle the compression.
56
     *
57 9
     * @return boolean
58
     */
59 9
    public function handledCompression()
60
    {
61
        return $this->handledCompression;
62
    }
63
64
    /**
65
     * Return data location.
66
     *
67
     * @return string
68 8
     * @throws \phpbu\App\Exception
69
     */
70 8
    public function getDataPath()
71 8
    {
72
        if ($this->handledCompression) {
73
            throw new Exception('source already handled compression');
74
        }
75
        return $this->dataPath;
76
    }
77
78
    /**
79
     * Static constructor for fluent interface calls.
80 3
     *
81
     * @return \phpbu\App\Backup\Source\Status
82 3
     */
83 1
    public static function create()
84
    {
85 2
        return new self();
86
    }
87
}
88