Completed
Push — develop ( eba420...e9b241 )
by Abdelrahman
02:33 queued 01:40
created

CustomInstaller   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 1
A getInstallPath() 0 16 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Composer\Installers;
6
7
use Composer\Package\PackageInterface;
8
9
class CustomInstaller extends LibraryInstaller
10
{
11
    /**
12
     * Decides if the installer supports the given type
13
     *
14
     * @param  string $packageType
15
     *
16
     * @return bool
17
     */
18
    public function supports($packageType)
19
    {
20
        return $packageType === 'cortex-custom';
21
    }
22
23
    /**
24
     * Returns the installation path of a package
25
     *
26
     * @param  PackageInterface $package
27
     *
28
     * @return string
29
     */
30
    public function getInstallPath(PackageInterface $package)
31
    {
32
        $rootExtra = $this->composer->getPackage()->getExtra();
33
34
        $packageName = $package->getName();
35
36
        if (isset($rootExtra['paths'][$packageName])) {
37
            return $rootExtra['paths'][$packageName];
38
        }
39
40
        $packageExtra = $package->getExtra();
41
42
        if (isset($packageExtra['path'])) {
43
            return $packageExtra['path'];
44
        }
45
    }
46
}
47