Completed
Push — master ( 4e395d...7b9c22 )
by Nikola
06:42
created

Process   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B execute() 0 27 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 Process
24
 *
25
 * Activity "Process": process backup files.
26
 *
27
 * @package RunOpenCode\Backup\Workflow
28
 */
29
class Process extends BaseActivity implements LoggerAwareInterface, EventDispatcherAwareInterface
30
{
31
    use LoggerAwareTrait;
32
    use EventDispatcherAwareTrait;
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 4
    public function execute()
38
    {
39 4
        $files = $this->backup->getFiles();
40 4
        $countIn = count($files);
41
42
        try {
43
44 4
            $this->backup->setFiles($this->profile->getProcessor()->process($files));
45
46 2
            $this->getEventDispatcher()->dispatch(BackupEvents::PROCESS, new BackupEvent($this, $this->profile, $this->backup, $this));
47
48
49 4
        } catch (\Exception $e) {
50
51 2
            $this->getLogger()->error(sprintf('Could not process source files for profile "%s".', $this->profile->getName()), array(
52 2
                'message' => $e->getMessage(),
53 2
                'code' => $e->getCode(),
54 2
                'file' => $e->getFile(),
55 2
                'line' => $e->getLine(),
56 2
                'trace' => $e->getTrace()
57 2
            ));
58
59 2
            throw $e;
60
        }
61
62 2
        $this->getLogger()->info(sprintf('Source files successfully processed, %s files in, %s out.', $countIn, count($this->backup->getFiles())));
63 2
    }
64
}
65