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

RadPHPInstaller   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A inflectPackageVars() 11 11 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Composer\Installers;
3
4 View Code Duplication
class RadPHPInstaller extends BaseInstaller
0 ignored issues
show
Duplication introduced by
This class 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...
5
{
6
    protected $locations = array(
7
        'bundle' => 'src/{$name}/'
8
    );
9
10
    /**
11
     * Format package name to CamelCase
12
     */
13
    public function inflectPackageVars($vars)
14
    {
15
        $nameParts = explode('/', $vars['name']);
16
        foreach ($nameParts as &$value) {
17
            $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
18
            $value = str_replace(array('-', '_'), ' ', $value);
19
            $value = str_replace(' ', '', ucwords($value));
20
        }
21
        $vars['name'] = implode('/', $nameParts);
22
        return $vars;
23
    }
24
}
25