Completed
Push — master ( 4dbd37...a699b3 )
by Sebastian
02:59
created

Sync::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 2
eloc 2
nc 2
nop 3
1
<?php
2
namespace phpbu\App\Runner;
3
4
use phpbu\App\Backup\Sync as SyncExe;
5
use phpbu\App\Backup\Sync\Simulator;
6
use phpbu\App\Backup\Target;
7
use phpbu\App\Result;
8
9
/**
10
 * Sync Runner
11
 *
12
 * @package    phpbu
13
 * @subpackage app
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 3.0.0
19
 */
20 View Code Duplication
class Sync extends Abstraction
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * Execute or simulate the sync.
24
     *
25
     * @param  \phpbu\App\Backup\Sync    $sync
26
     * @param  \phpbu\App\Backup\Target  $target
27
     * @param  \phpbu\App\Result         $result
28
     * @throws \phpbu\App\Exception
29
     */
30
    public function run(SyncExe $sync, Target $target, Result $result)
31
    {
32
        $this->isSimulation() ? $this->simulate($sync, $target, $result) : $this->runSync($sync, $target, $result);
33
    }
34
35
    /**
36
     * Execute the sync.
37
     *
38
     * @param  \phpbu\App\Backup\Sync    $sync
39
     * @param  \phpbu\App\Backup\Target  $target
40
     * @param  \phpbu\App\Result         $result
41
     * @throws \phpbu\App\Exception
42
     */
43
    protected function runSync(SyncExe $sync, Target $target, Result $result)
44
    {
45
        $sync->sync($target, $result);
46
    }
47
48
    /**
49
     * Simulate the sync process.
50
     *
51
     * @param  \phpbu\App\Backup\Sync    $sync
52
     * @param  \phpbu\App\Backup\Target  $target
53
     * @param  \phpbu\App\Result         $result
54
     * @throws \phpbu\App\Exception
55
     */
56
    protected function simulate(SyncExe $sync, Target $target, Result $result)
57
    {
58
        if ($sync instanceof Simulator) {
59
            $sync->simulate($target, $result);
60
        }
61
    }
62
}
63