Passed
Push — master ( 9fa0e9...00086e )
by Andrea
16:10
created

StringUtils   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A toCamelCase() 0 13 3
1
<?php
2
3
namespace Cdf\BiCoreBundle\Utils\String;
4
5
class StringUtils
6
{
7
    /**
8
     * Translates a string with underscores into camel case (e.g. first_name -&gt; firstName).
9
     *
10
     * @param array $parametri
11
     *
12
     * @return string $str translated into camel caps
13
     */
14 3
    public static function toCamelCase($parametri = array())
15
    {
16 3
        $str = $parametri['str'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 19 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
17 3
        $capitalise_first_char = isset($parametri['primamaiuscola']) ? $parametri['primamaiuscola'] : false;
18
19 3
        if ($capitalise_first_char) {
20 3
            $str[0] = strtoupper($str[0]);
21
        }
22 3
        $func = function ($matches) {
23 2
            return strtoupper($matches[1]);
24 3
        };
25
26 3
        return preg_replace_callback('/_([a-z])/', $func, $str);
27
    }
28
}
29