Composer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 49
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getKnownPaths() 0 8 1
A setBinary() 0 10 2
A getDependenciesFolder() 0 4 1
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\Binaries\PackageManagers;
14
15
use Rocketeer\Binaries\Php;
16
17
/**
18
 * Provides methods to manage a Composer application.
19
 */
20
class Composer extends AbstractPackageManager
21
{
22
    /**
23
     * The name of the manifest file to look for.
24
     *
25
     * @var string
26
     */
27
    protected $manifest = 'composer.json';
28
29
    /**
30
     * Get an array of default paths to look for.
31
     *
32
     * @return string[]
33
     */
34 42
    protected function getKnownPaths()
35
    {
36
        return [
37 42
            'composer',
38 42
            $this->paths->getHomeFolder().'/composer.phar',
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method getHomeFolder 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...
39 42
            $this->releasesManager->getCurrentReleasePath().'/composer.phar',
40 42
        ];
41
    }
42
43
    /**
44
     * Change Composer's binary.
45
     *
46
     * @param string $binary
47
     */
48 44
    public function setBinary($binary)
49
    {
50 44
        parent::setBinary($binary);
51
52
        // Prepend PHP command if executing from archive
53 44
        if (mb_strpos($binary, 'composer.phar') !== false) {
54 2
            $php = new Php($this->container);
55 2
            $this->setParent($php);
56 2
        }
57 44
    }
58
59
    /**
60
     * Get where dependencies are installed.
61
     *
62
     * @return string
63
     */
64 8
    public function getDependenciesFolder()
65
    {
66 8
        return 'vendor';
67
    }
68
}
69