Completed
Push — master ( 3563e8...eabdc7 )
by Nikola
04:08
created

Push   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 2
c 3
b 0
f 1
lcom 1
cbo 9
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 23 2
1
<?php
2
/*
3
 * This file is part of the Backup package, an RunOpenCode project.
4
 *
5
 * (c) 2015 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * This project is fork of "kbond/php-backup", for full credits info, please
11
 * view CREDITS file that was distributed with this source code.
12
 */
13
namespace RunOpenCode\Backup\Workflow;
14
15
use RunOpenCode\Backup\Contract\EventDispatcherAwareInterface;
16
use RunOpenCode\Backup\Contract\LoggerAwareInterface;
17
use RunOpenCode\Backup\Event\BackupEvent;
18
use RunOpenCode\Backup\Event\BackupEvents;
19
use RunOpenCode\Backup\Event\EventDispatcherAwareTrait;
20
use RunOpenCode\Backup\Log\LoggerAwareTrait;
21
22
/**
23
 * Class Push
24
 *
25
 * Activity "Push": push backups to destination.
26
 *
27
 * @package RunOpenCode\Backup\Workflow
28
 */
29
class Push extends BaseActivity implements LoggerAwareInterface, EventDispatcherAwareInterface
30
{
31
    use LoggerAwareTrait;
32
    use EventDispatcherAwareTrait;
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 4
    public function execute()
0 ignored issues
show
Duplication introduced by
This method 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...
38
    {
39
        try {
40
41 4
            $this->profile->getDestination()->push($this->backup);
42
43 2
            $this->getEventDispatcher()->dispatch(BackupEvents::PUSH, new BackupEvent($this, $this->profile, $this->backup, $this));
44
45 2
            $this->getLogger()->info(sprintf('Backup "%s" successfully pushed to destination.', $this->backup->getName()));
46
47 4
        } catch (\Exception $e) {
48
49 2
            $this->getLogger()->error(sprintf('Could not push backup to destination for profile "%s".', $this->profile->getName()), array(
50 2
                'message' => $e->getMessage(),
51 2
                'code' => $e->getCode(),
52 2
                'file' => $e->getFile(),
53 2
                'line' => $e->getLine(),
54 2
                'trace' => $e->getTrace()
55 2
            ));
56
57 2
            throw $e;
58
        }
59 2
    }
60
}
61