Passed
Push — master ( 1d60eb...03dff3 )
by Stiofan
06:44 queued 03:02
created

GravInstaller::inflectPackageVars()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
namespace Composer\Installers;
3
4
class GravInstaller extends BaseInstaller
5
{
6
    protected $locations = array(
7
        'plugin' => 'user/plugins/{$name}/',
8
        'theme'  => 'user/themes/{$name}/',
9
    );
10
11
    /**
12
     * Format package name
13
     *
14
     * @param array $vars
15
     *
16
     * @return array
17
     */
18
    public function inflectPackageVars($vars)
19
    {
20
        $restrictedWords = implode('|', array_keys($this->locations));
21
22
        $vars['name'] = strtolower($vars['name']);
23
        $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
24
            '$1',
25
            $vars['name']
26
        );
27
28
        return $vars;
29
    }
30
}
31