Completed
Push — master ( d9186d...be21d0 )
by Abdelrahman
01:39 queued 11s
created

CustomInstaller::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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