Status   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 88
ccs 17
cts 17
cp 1
rs 10
c 2
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A uncompressedFile() 0 5 1
A uncompressedDirectory() 0 4 1
A getDataPath() 0 6 2
A handledCompression() 0 3 1
A create() 0 3 1
A isDirectory() 0 3 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 = 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