Completed
Push — master ( d3a073...5737c8 )
by Greg
02:21
created

src/Task/Bower/Base.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Robo\Task\Bower;
3
4
use Robo\Task\BaseTask;
5
use Robo\Exception\TaskException;
6
7
abstract class Base extends BaseTask
8
{
9
    use \Robo\Common\ExecOneCommand;
10
11
    protected $opts = [];
12
    protected $action = '';
13
14
    /**
15
     * @var string
16
     */
17
    protected $command = '';
18
19
    /**
20
     * adds `allow-root` option to bower
21
     *
22
     * @return $this
23
     */
24
    public function allowRoot()
25
    {
26
        $this->option('allow-root');
27
        return $this;
28
    }
29
30
    /**
31
     * adds `force-latest` option to bower
32
     *
33
     * @return $this
34
     */
35
    public function forceLatest()
36
    {
37
        $this->option('force-latest');
38
        return $this;
39
    }
40
41
    /**
42
     * adds `production` option to bower
43
     *
44
     * @return $this
45
     */
46
    public function noDev()
47
    {
48
        $this->option('production');
49
        return $this;
50
    }
51
52
    /**
53
     * adds `offline` option to bower
54
     *
55
     * @return $this
56
     */
57
    public function offline()
58
    {
59
        $this->option('offline');
60
        return $this;
61
    }
62
63
    /**
64
     * Base constructor.
65
     *
66
     * @param null|string $pathToBower
67
     *
68
     * @throws \Robo\Exception\TaskException
69
     */
70 View Code Duplication
    public function __construct($pathToBower = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        $this->command = $pathToBower;
73
        if (!$this->command) {
74
            $this->command = $this->findExecutable('bower');
75
        }
76
        if (!$this->command) {
77
            throw new TaskException(__CLASS__, "Bower executable not found.");
78
        }
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getCommand()
85
    {
86
        return "{$this->command} {$this->action}{$this->arguments}";
87
    }
88
}
89