Installer::getInstallPath()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
/**
4
 * @package GPL Cart composer module installer
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2017, Iurii Makukh <[email protected]>
7
 * @license https://www.gnu.org/licenses/gpl.html GNU/GPLv3
8
 */
9
10
namespace Gplcart\Composer\ModuleInstaller;
11
12
use Composer\Package\PackageInterface;
13
use Composer\Installer\LibraryInstaller;
14
15
class Installer extends LibraryInstaller
16
{
17
18
    /**
19
     * @param PackageInterface $package
20
     * @return string
21
     */
22
    public function getInstallPath(PackageInterface $package)
23
    {
24
        if (!file_exists(getcwd() . '/system/modules')) {
25
            throw new \LogicException('Module directory not found. You have to install modules from root directory');
26
        }
27
28
        $parts = explode('/', $package->getPrettyName(), 2);
29
        return "system/modules/{$parts[1]}";
30
    }
31
32
    /**
33
     * @param string $packageType
34
     * @return bool
35
     */
36
    public function supports($packageType)
37
    {
38
        return 'gplcart-module' === $packageType;
39
    }
40
41
}
42