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

MediaWikiInstaller::inflectSkinVars()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Composer\Installers;
3
4
class MediaWikiInstaller extends BaseInstaller
5
{
6
    protected $locations = array(
7
        'core' => 'core/',
8
        'extension' => 'extensions/{$name}/',
9
        'skin' => 'skins/{$name}/',
10
    );
11
12
    /**
13
     * Format package name.
14
     *
15
     * For package type mediawiki-extension, cut off a trailing '-extension' if present and transform
16
     * to CamelCase keeping existing uppercase chars.
17
     *
18
     * For package type mediawiki-skin, cut off a trailing '-skin' if present.
19
     *
20
     */
21
    public function inflectPackageVars($vars)
22
    {
23
24
        if ($vars['type'] === 'mediawiki-extension') {
25
            return $this->inflectExtensionVars($vars);
26
        }
27
28
        if ($vars['type'] === 'mediawiki-skin') {
29
            return $this->inflectSkinVars($vars);
30
        }
31
32
        return $vars;
33
    }
34
35 View Code Duplication
    protected function inflectExtensionVars($vars)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $vars['name'] = preg_replace('/-extension$/', '', $vars['name']);
38
        $vars['name'] = str_replace('-', ' ', $vars['name']);
39
        $vars['name'] = str_replace(' ', '', ucwords($vars['name']));
40
41
        return $vars;
42
    }
43
44
    protected function inflectSkinVars($vars)
45
    {
46
        $vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
47
48
        return $vars;
49
    }
50
51
}
52