Code Duplication    Length = 43-44 lines in 2 locations

src/Runner/Crypter.php 1 location

@@ 20-63 (lines=44) @@
17
 * @link       http://phpbu.de/
18
 * @since      Class available since Release 3.0.0
19
 */
20
class Crypter extends Abstraction
21
{
22
    /**
23
     * Execute or simulate the encryption.
24
     *
25
     * @param  \phpbu\App\Backup\Crypter $crypter
26
     * @param  \phpbu\App\Backup\Target  $target
27
     * @param  \phpbu\App\Result         $result
28
     * @throws \phpbu\App\Exception
29
     */
30
    public function run(CrypterExe $crypter, Target $target, Result $result)
31
    {
32
        $this->isSimulation() ? $this->simulate($crypter, $target, $result) : $this->crypt($crypter, $target, $result);
33
        $target->setCrypter($crypter);
34
    }
35
36
    /**
37
     * Execute the encryption.
38
     *
39
     * @param  \phpbu\App\Backup\Crypter $crypter
40
     * @param  \phpbu\App\Backup\Target  $target
41
     * @param  \phpbu\App\Result         $result
42
     * @throws \phpbu\App\Exception
43
     */
44
    protected function crypt(CrypterExe $crypter, Target $target, Result $result)
45
    {
46
        $crypter->crypt($target, $result);
47
    }
48
49
    /**
50
     * Simulate the encryption.
51
     *
52
     * @param  \phpbu\App\Backup\Crypter $crypter
53
     * @param  \phpbu\App\Backup\Target  $target
54
     * @param  \phpbu\App\Result         $result
55
     * @throws \phpbu\App\Exception
56
     */
57
    protected function simulate(CrypterExe $crypter, Target $target, Result $result)
58
    {
59
        if ($crypter instanceof Simulator) {
60
            $crypter->simulate($target, $result);
61
        }
62
    }
63
}
64

src/Runner/Sync.php 1 location

@@ 20-62 (lines=43) @@
17
 * @link       http://phpbu.de/
18
 * @since      Class available since Release 3.0.0
19
 */
20
class Sync extends Abstraction
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