Status::isDirectory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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