ThemeInstaller   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstallPath() 0 13 3
A supports() 0 4 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
}