Completed
Pull Request — master (#145)
by Vitaly
02:37
created

Sync   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 41
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
setup() 0 1 ?
sync() 0 1 ?
A validateConfig() 0 8 3
1
<?php
2
namespace phpbu\App\Backup;
3
4
use phpbu\App\Backup\Sync\Exception;
5
use phpbu\App\Backup\Sync\Simulator;
6
use phpbu\App\Result;
7
use phpbu\App\Util;
8
9
/**
10
 * Sync
11
 *
12
 * @package    phpbu
13
 * @subpackage Backup
14
 * @author     Sebastian Feldmann <[email protected]>
15
 * @copyright  Sebastian Feldmann <[email protected]>
16
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
17
 * @link       http://phpbu.de/
18
 * @since      Class available since Release 1.0.0
19
 */
20
abstract class Sync implements Simulator
21
{
22
    /**
23
     * Unix timestamp of generating path from placeholder.
24
     *
25
     * @var int
26
     */
27
    protected $time;
28
29
    /**
30
     * Setup the Sync object with all xml options.
31
     *
32
     * @param array $options
33
     */
34
    abstract public function setup(array $options);
35
36
    /**
37
     * Execute the Sync
38
     * Copy your backup to another location
39
     *
40
     * @param \phpbu\App\Backup\Target $target
41
     * @param \phpbu\App\Result        $result
42
     */
43
    abstract public function sync(Target $target, Result $result);
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
44
45
    /**
46
     * Make sure all mandatory keys are present in given config.
47
     *
48
     * @param  array $config
49
     * @param  array $keys
50
     * @throws Exception
51
     */
52 30
    protected function validateConfig(array $config, array $keys)
53
    {
54 30
        foreach ($keys as $option) {
55 30
            if (!Util\Arr::isSetAndNotEmptyString($config, $option)) {
56 30
                throw new Exception($option . ' is mandatory');
57
            }
58
        }
59 13
    }
60
}
61