Failed Conditions
Push — develop ( 17c62d...454191 )
by Maxime
22:00 queued 02:09
created

Installer::execute()   A

Complexity

Conditions 4
Paths 8

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 19
Code Lines 11

Code Coverage

Tests 13
CRAP Score 4

Importance

Changes 6
Bugs 0 Features 0
Metric Value
c 6
b 0
f 0
dl 0
loc 19
ccs 13
cts 13
cp 1
rs 9.2
cc 4
eloc 11
nc 8
nop 0
crap 4
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 */
12
13
namespace Rocketeer\Tasks\Plugins;
14
15
use Rocketeer\Tasks\AbstractTask;
16
17
/**
18
 * Installs one or more plugins.
19
 */
20
class Installer extends AbstractTask
21
{
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
    protected $description = 'Installs one or more plugins';
28
29
    /**
30
     * Whether to run the commands locally
31
     * or on the server.
32
     *
33
     * @var bool
34
     */
35
    protected $local = true;
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function execute()
41
    {
42
        // Get package and destination folder
43 1
        $package = $this->command->argument('package');
44
45 1
        if (!$this->files->has($this->paths->getRocketeerPath().'/composer.json')) {
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method getRocketeerPath does not exist on object<Rocketeer\Services\Environment\Pathfinder>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
46 1
            $this->igniter->exportComposerFile();
47 1
        }
48
49 1
        $method = $package ? 'require' : 'install';
50 1
        $noDev = $method === 'install' ? '--no-dev' : '--update-no-dev';
51 1
        $options = [$noDev => '', '--working-dir' => $this->paths->getRocketeerPath()];
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method getRocketeerPath does not exist on object<Rocketeer\Services\Environment\Pathfinder>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
52 1
        $env = ['COMPOSER_DISCARD_CHANGES' => 1];
53
54
        // Install plugin
55 1
        $this->explainer->line('Installing '.$package);
56 1
        $command = $this->composer()->$method($package, $options, $env);
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method composer does not exist on object<Rocketeer\Tasks\Plugins\Installer>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
57 1
        $this->run($this->shellCommand($command));
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method shellCommand does not exist on object<Rocketeer\Tasks\Plugins\Installer>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
58 1
    }
59
}
60