Completed
Push — master ( 6d6579...e709ba )
by Greg
02:53
created

RequireDependency::noSuggest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Robo\Task\Composer;
4
5
/**
6
 * Composer Require
7
 *
8
 * ``` php
9
 * <?php
10
 * // simple execution
11
 * $this->taskComposerRequire()->dependency('foo/bar', '^.2.4.8')->run();
12
 * ?>
13
 * ```
14
 */
15
class RequireDependency extends Base
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected $action = 'require';
21
22
    /**
23
     * 'require' is a keyword, so it cannot be a method name.
24
     *
25
     * @param string $project
26
     * @param null|string $version
27
     *
28
     * @return $this
29
     */
30
    public function dependency($project, $version = null)
31
    {
32
        $project = (array)$project;
33
34
        if (isset($version)) {
35
            $project = array_map(
36
                function ($item) use ($version) {
37
                    return "$item:$version";
38
                },
39
                $project
40
            );
41
        }
42
        $this->args($project);
43
        return $this;
44
    }
45
46
    /**
47
     * adds `no-suggest` option to composer
48
     *
49
     * @param bool $noSuggest
50
     *
51
     * @return $this
52
     */
53
    public function noSuggest($noSuggest = true)
0 ignored issues
show
Unused Code introduced by
The parameter $noSuggest is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
54
    {
55
        $this->option('--no-suggest');
56
        return $this;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function run()
63
    {
64
        $command = $this->getCommand();
65
        $this->printTaskInfo('Requiring packages: {command}', ['command' => $command]);
66
        return $this->executeCommand($command);
67
    }
68
}
69