Completed
Push — master ( 9d0750...b73b31 )
by Sebastian
10:06
created

Status::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 0
cts 0
cp 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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 = true;
25
26
    /**
27
     * Is created backup a directory
28
     *
29
     * @var bool
30
     */
31
    private $dataPathIsDir = false;
32
33
    /**
34
     * Path to generated source data.
35
     *
36 12
     * @var string
37
     */
38 12
    private $dataPath;
39 12
40
41
    /**
42
     * Source does not handle compression.
43
     *
44
     * @deprecated use uncompressedFile instead
45
     * @param      string $path
46 8
     * @return     \phpbu\App\Backup\Source\Status
47
     */
48 8
    public function uncompressed($path)
49 8
    {
50
        return $this->uncompressedFile($path);
51
    }
52
53
    /**
54
     * Source does not handle compression.
55
     *
56
     * @param  string $path
57 9
     * @return \phpbu\App\Backup\Source\Status
58
     */
59 9
    public function uncompressedFile($path)
60
    {
61
        $this->handledCompression = false;
62
        $this->dataPath           = $path;
63
        return $this;
64
    }
65
66
    /**
67
     * @param $path
68 8
     * @return \phpbu\App\Backup\Source\Status
69
     */
70 8
    public function uncompressedDirectory($path)
71 8
    {
72
        $this->dataPathIsDir = true;
73
        return $this->uncompressedFile($path);
74
    }
75
76
    /**
77
     * Did the Source handle the compression.
78
     *
79
     * @return boolean
80 3
     */
81
    public function handledCompression()
82 3
    {
83 1
        return $this->handledCompression;
84
    }
85 2
86
    /**
87
     * Is created backup data a directory.
88
     *
89
     * @return bool
90
     */
91
    public function isDirectory()
92
    {
93 12
        return $this->dataPathIsDir;
94
    }
95 12
96
    /**
97
     * Return data location.
98
     *
99
     * @return string
100
     * @throws \phpbu\App\Exception
101
     */
102
    public function getDataPath()
103
    {
104
        if ($this->handledCompression) {
105
            throw new Exception('source already handled compression');
106
        }
107
        return $this->dataPath;
108
    }
109
110
    /**
111
     * Static constructor for fluent interface calls.
112
     *
113
     * @return \phpbu\App\Backup\Source\Status
114
     */
115
    public static function create()
116
    {
117
        return new self();
118
    }
119
}
120