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

File::getExecutable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
namespace phpbu\App\Backup\Compressor;
3
4
use phpbu\App\Backup\Target;
5
use phpbu\App\Cli\Executable\Compressor;
6
use phpbu\App\Result;
7
8
/**
9
 * File
10
 *
11
 * @package    phpbu
12
 * @subpackage Backup
13
 * @author     Sebastian Feldmann <[email protected]>
14
 * @copyright  Sebastian Feldmann <[email protected]>
15
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
16
 * @link       http://phpbu.de/
17
 * @since      Class available since Release 2.1.0
18
 */
19
class File extends Abstraction
20
{
21
    /**
22
     * Validate path.
23
     *
24
     * @param  string $path
25
     * @return boolean
26
     */
27
    public function isPathValid($path)
28
    {
29 5
        return is_file($path);
30
    }
31 5
32
    /**
33
     * Returns the executable for this action.
34
     *
35
     * @param  \phpbu\App\Backup\Target $target
36
     * @return \phpbu\App\Cli\Executable
37
     */
38
    public function getExecutable(Target $target) {
39
        if (null === $this->executable) {
40 3
            $this->executable = new Compressor($target->getCompressor()->getCommand(), $this->pathToCommand);
41 3
            $this->executable->force(true)->compressFile($this->path);
42 1
        }
43 1
        return $this->executable;
44 1
    }
45 1
46 3
47
    /**
48
     * Return final archive file.
49
     *
50
     * @param  \phpbu\App\Backup\Target $target
51
     * @return string
52
     */
53
    public function getArchiveFile(Target $target)
54
    {
55
        return $target->getPathname();
56
    }
57
}
58