ThemeInstaller::getInstallPath()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 3
eloc 7
nc 2
nop 1
1
<?php
2
/*
3
 * This file is part of the phpdish/theme-installer package.
4
 *
5
 * (c) Slince <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PHPDish\ThemeInstaller;
12
13
use Composer\Installer\LibraryInstaller;
14
use Composer\Package\PackageInterface;
15
16
class ThemeInstaller extends LibraryInstaller
17
{
18
    /**
19
     * 模板路径.
20
     *
21
     * @var string
22
     */
23
    const THEME_PATH = 'app/themes/';
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function getInstallPath(PackageInterface $package)
29
    {
30
        $this->filesystem->ensureDirectoryExists(static::THEME_PATH);
31
32
        $name = $package->getPrettyName();
33
34
        $rootPackage = $this->composer->getPackage()->getConfig();
35
        if (isset($rootPackage['ignore-theme-vendor']) && true === $rootPackage['ignore-theme-vendor']) {
36
            list(, $name) = explode('/', $name, 2);
37
        }
38
39
        return  static::THEME_PATH.$name;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function supports($packageType)
46
    {
47
        return 'phpdish-theme' === $packageType;
48
    }
49
}