Completed
Pull Request — master (#2)
by Tim
02:51
created

AbstractRoboFile::sync()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 1
1
<?php
2
3
/**
4
 * AppserverIo\RoboTasks\AbstractRoboFile
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/robo-tasks
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\RoboTasks;
22
23
use Robo\Robo;
24
use Robo\Tasks;
25
26
/**
27
 * Abstract implementation of a Robo configuration class.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2015 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/appserver-io/robo-tasks
33
 * @link      http://www.appserver.io
34
 */
35
abstract class AbstractRoboFile extends Tasks
36
{
37
38
    /**
39
     * Load the appserver.io base tasks.
40
     *
41
     * @var \AppserverIo\RoboTasks\Base\loadTasks
42
     */
43
    use Base\loadTasks;
44
45
    /**
46
     * The sync command implementation.
47
     *
48
     * @param array $opts The command OptionsHookDispatcher
49
     *
50
     * @return void
51
     */
52
    public function sync(array $opts = [InputOptionKeys::SRC => null, InputOptionKeys::DEST => null])
53
    {
54
55
        // load the task
56
        $task = $this->taskSync();
57
58
        // set source directory
59
        if (isset($opts[InputOptionKeys::SRC])) {
60
            $task->src($opts[InputOptionKeys::SRC]);
61
        }
62
63
        // set target directory
64
        if (isset($opts[InputOptionKeys::DEST])) {
65
            $task->dest($opts[InputOptionKeys::DEST]);
66
        }
67
68
        // run the task
69
        $task->run();
70
    }
71
}
72