|
1
|
|
|
<?php |
|
2
|
|
|
namespace phpbu\App\Backup\Crypter; |
|
3
|
|
|
|
|
4
|
|
|
use phpbu\App\Backup\Cli; |
|
5
|
|
|
use phpbu\App\Backup\Crypter; |
|
6
|
|
|
use phpbu\App\Backup\Target; |
|
7
|
|
|
use phpbu\App\Cli\Executable; |
|
8
|
|
|
use phpbu\App\Result; |
|
9
|
|
|
use phpbu\App\Util; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Abstract crypter class. |
|
13
|
|
|
* |
|
14
|
|
|
* @package phpbu |
|
15
|
|
|
* @subpackage Backup |
|
16
|
|
|
* @author Sebastian Feldmann <[email protected]> |
|
17
|
|
|
* @copyright Sebastian Feldmann <[email protected]> |
|
18
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
|
19
|
|
|
* @link http://phpbu.de/ |
|
20
|
|
|
* @since Class available since Release 2.1.6 |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class Abstraction extends Cli |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* (non-PHPDoc) |
|
26
|
|
|
* |
|
27
|
|
|
* @see \phpbu\App\Backup\Crypter |
|
28
|
|
|
* @param \phpbu\App\Backup\Target $target |
|
29
|
|
|
* @param \phpbu\App\Result $result |
|
30
|
|
|
* @throws Exception |
|
31
|
|
|
*/ |
|
32
|
|
|
public function crypt(Target $target, Result $result) |
|
33
|
|
|
{ |
|
34
|
|
|
$crypt = $this->execute($target); |
|
35
|
|
|
$name = strtolower(get_class($this)); |
|
36
|
|
|
|
|
37
|
|
|
$result->debug($name . ':' . $crypt->getCmd()); |
|
38
|
|
|
|
|
39
|
|
|
if (!$crypt->wasSuccessful()) { |
|
40
|
|
|
throw new Exception($name . ' failed:' . PHP_EOL . $crypt->getStdErr()); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Simulate the encryption. |
|
46
|
|
|
* |
|
47
|
|
|
* @param \phpbu\App\Backup\Target $target |
|
48
|
|
|
* @param \phpbu\App\Result $result |
|
49
|
|
|
*/ |
|
50
|
|
|
public function simulate(Target $target, Result $result) |
|
51
|
|
|
{ |
|
52
|
|
|
$result->debug( |
|
53
|
|
|
'execute encryption:' . PHP_EOL . |
|
54
|
|
|
$this->getExecutable($target)->getCmd() |
|
|
|
|
|
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Return an absolute path relative to the used file. |
|
60
|
|
|
* |
|
61
|
|
|
* @param string $path |
|
62
|
|
|
* @param string $default |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function toAbsolutePath($path, $default = null) |
|
66
|
|
|
{ |
|
67
|
|
|
return !empty($path) ? Util\Cli::toAbsolutePath($path, Util\Cli::getBase('configuration')) : $default; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.