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

DokuWikiInstaller::inflectPackageVars()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
namespace Composer\Installers;
3
4
class DokuWikiInstaller extends BaseInstaller
5
{
6
    protected $locations = array(
7
        'plugin' => 'lib/plugins/{$name}/',
8
        'template' => 'lib/tpl/{$name}/',
9
    );
10
11
    /**
12
     * Format package name.
13
     *
14
     * For package type dokuwiki-plugin, cut off a trailing '-plugin', 
15
     * or leading dokuwiki_ if present.
16
     * 
17
     * For package type dokuwiki-template, cut off a trailing '-template' if present.
18
     *
19
     */
20
    public function inflectPackageVars($vars)
21
    {
22
23
        if ($vars['type'] === 'dokuwiki-plugin') {
24
            return $this->inflectPluginVars($vars);
25
        }
26
27
        if ($vars['type'] === 'dokuwiki-template') {
28
            return $this->inflectTemplateVars($vars);
29
        }
30
31
        return $vars;
32
    }
33
34 View Code Duplication
    protected function inflectPluginVars($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...
35
    {
36
        $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
37
        $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
38
39
        return $vars;
40
    }
41
42 View Code Duplication
    protected function inflectTemplateVars($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...
43
    {
44
        $vars['name'] = preg_replace('/-template$/', '', $vars['name']);
45
        $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
46
47
        return $vars;
48
    }
49
50
}
51