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

GravInstaller   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A inflectPackageVars() 0 12 1
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