Completed
Pull Request — master (#586)
by Greg
05:01
created

CreateProject::buildCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
namespace Robo\Task\Composer;
3
4
/**
5
 * Composer CreateProject
6
 *
7
 * ``` php
8
 * <?php
9
 * // simple execution
10
 * $this->taskComposerCreateProject()->source('foo/bar')->target('myBar')->run();
11
 * ?>
12
 * ```
13
 */
14
class CreateProject extends Base
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    protected $action = 'create-project';
20
21
    protected $source;
22
    protected $target = '';
23
    protected $version = '';
24
25
    /**
26
     * @return $this
27
     */
28
    public function source($source)
29
    {
30
        $this->source = $source;
31
        return $this;
32
    }
33
34
    /**
35
     * @return $this
36
     */
37
    public function target($target)
38
    {
39
        $this->target = $target;
40
        return $this;
41
    }
42
43
    /**
44
     * @return $this
45
     */
46
    public function version($version)
47
    {
48
        $this->version = $version;
49
        return $this;
50
    }
51
52
    public function keepVcs()
53
    {
54
        $this->option('--keep-vcs');
55
        return $this;
56
    }
57
58
    public function noInstall()
59
    {
60
        $this->option('--no-install');
61
        return $this;
62
    }
63
64
    /**
65
     * @return $this
66
     */
67
    public function repository($repository)
68
    {
69
        $this->option('repository', $repository);
70
        return $this;
71
    }
72
73
    public function buildCommand()
74
    {
75
        $this->arg($this->source);
76
        $this->arg($this->target);
77
        $this->arg($this->version);
78
79
        return parent::buildCommand();
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function run()
86
    {
87
        $command = $this->getCommand();
88
        $this->printTaskInfo('Creating project: {command}', ['command' => $command]);
89
        return $this->executeCommand($command);
90
    }
91
}
92