Completed
Push — master ( c0fe4a...c6a3ae )
by Yuri
02:52
created

Formatter::lower()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Tamtamchik\NameCase;
2
3
/**
4
 * Class Formatter.
5
 */
6
class Formatter
7
{
8
    const DEFAULT_OPTIONS = [
9
        'lazy'    => true,
10
        'irish'   => true,
11
        'spanish' => true,
12
    ];
13
14
    private static function upper($matches)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
15
    {
16
        return strtoupper($matches[0]);
17
    }
18
19
    private static function lower($matches)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
20
    {
21
        return strtolower($matches[0]);
22
    }
23
24
    /**
25
     * @param string $string
26
     * @param array  $options
27
     *
28
     * @return string
29
     */
30
    public static function nc($string, array $options = [])
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
    {
32
        //$options = array_merge(self::DEFAULT_OPTIONS, $options);
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
        //
34
        ////Skip if string is mixed case
35
        //if ($options['lazy']) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
36
        //    $firstLetterLower = $string[0] == strtolower($string[0]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
        //    $allLowerOrUpper  = (strtolower($string) == $string || strtoupper($string) == $string);
0 ignored issues
show
Unused Code Comprehensibility introduced by
49% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
        //
39
        //    if ( ! $firstLetterLower || ! $allLowerOrUpper) return $string;
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
        //}
41
42
        $local = strtolower($string);
43
44
        // Capitalize
45
        $local = preg_replace_callback('/\b\w/', function ($matches) {
46
            return strtoupper($matches[0]);
47
        }, $local);
48
49
        $local = preg_replace_callback('/\'\w\b/', function ($matches) {
50
            return strtolower($matches[0]);
51
        }, $local); # Lowercase 's
52
53
        return $local;
54
    }
55
}
56