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

File::isPathValid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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