Completed
Pull Request — master (#586)
by Greg
03:29
created

CreateProject::noInstall()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
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($keep = true)
53
    {
54
        if ($keep) {
55
            $this->option('--keep-vcs');
56
        }
57
        return $this;
58
    }
59
60
    public function noInstall($noInstall = true)
61
    {
62
        if ($noInstall) {
63
            $this->option('--no-install');
64
        }
65
        return $this;
66
    }
67
68
    /**
69
     * @return $this
70
     */
71
    public function repository($repository)
72
    {
73
        $this->option('repository', $repository);
74
        return $this;
75
    }
76
77
    public function buildCommand()
78
    {
79
        $this->arg($this->source);
80
        $this->arg($this->target);
81
        $this->arg($this->version);
82
83
        return parent::buildCommand();
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function run()
90
    {
91
        $command = $this->getCommand();
92
        $this->printTaskInfo('Creating project: {command}', ['command' => $command]);
93
        return $this->executeCommand($command);
94
    }
95
}
96