Failed Conditions
Push — develop ( 97d950...17c62d )
by Maxime
19:32
created

Installer::execute()   B

Complexity

Conditions 4
Paths 8

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 22
Code Lines 12

Code Coverage

Tests 16
CRAP Score 4

Importance

Changes 5
Bugs 0 Features 0
Metric Value
dl 0
loc 22
ccs 16
cts 16
cp 1
rs 8.9197
c 5
b 0
f 0
cc 4
eloc 12
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
     * [email protected]}
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\Service...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
        $command = $this->composer()->$method($package, [
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...
52 1
            $noDev => '',
53 1
            '--working-dir' => $this->paths->getRocketeerPath(),
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method getRocketeerPath does not exist on object<Rocketeer\Service...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...
54 1
        ], [
55 1
            'COMPOSER_DISCARD_CHANGES' => 1,
56 1
        ]);
57
58
        // Install plugin
59 1
        $this->explainer->line('Installing '.$package);
60 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...
61 1
    }
62
}
63