GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CaseManipulators::lowerCaseFirst()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php namespace Gears\String\Methods;
2
////////////////////////////////////////////////////////////////////////////////
3
// __________ __             ________                   __________
4
// \______   \  |__ ______  /  _____/  ____ _____ ______\______   \ _______  ___
5
//  |     ___/  |  \\____ \/   \  ____/ __ \\__  \\_  __ \    |  _//  _ \  \/  /
6
//  |    |   |   Y  \  |_> >    \_\  \  ___/ / __ \|  | \/    |   (  <_> >    <
7
//  |____|   |___|  /   __/ \______  /\___  >____  /__|  |______  /\____/__/\_ \
8
//                \/|__|           \/     \/     \/             \/            \/
9
// -----------------------------------------------------------------------------
10
//          Designed and Developed by Brad Jones <brad @="bjc.id.au" />
11
// -----------------------------------------------------------------------------
12
////////////////////////////////////////////////////////////////////////////////
13
14
use voku\helper\UTF8;
15
16
trait CaseManipulators
17
{
18
    /**
19
     * Converts the first character of the string to lower case.
20
     *
21
     * @return static String with the first character of $str being lower case
22
     */
23 View Code Duplication
    public function lowerCaseFirst()
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...
24
    {
25
        $first = UTF8::substr($this->scalarString, 0, 1, $this->encoding);
26
27
        $rest = UTF8::substr
28
        (
29
            $this->scalarString,
30
            1,
31
            $this->getLength() - 1,
32
            $this->encoding
33
        );
34
35
        return $this->newSelf(UTF8::strtolower($first, $this->encoding).$rest);
36
    }
37
38
    /**
39
     * Converts the first character of the supplied string to upper case.
40
     *
41
     * @return static String with the first character of $str being upper case
42
     */
43 View Code Duplication
    public function upperCaseFirst()
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...
44
    {
45
        $first = UTF8::substr($this->scalarString, 0, 1, $this->encoding);
46
47
        $rest = UTF8::substr
48
        (
49
            $this->scalarString,
50
            1,
51
            $this->getLength() - 1,
52
            $this->encoding
53
        );
54
55
        return $this->newSelf(UTF8::strtoupper($first, $this->encoding).$rest);
56
    }
57
58
    /**
59
     * Returns a case swapped version of the string.
60
     *
61
     * @return Stringy Object whose $str has each character's case swapped
62
     */
63
    public function swapCase()
64
    {
65
        return $this->newSelf(preg_replace_callback
66
        (
67
            '/[\S]/u',
68
            function ($match)
69
            {
70
                $marchToUpper = UTF8::strtoupper($match[0], $this->encoding);
71
72
                if ($match[0] == $marchToUpper)
73
                {
74
                    return UTF8::strtolower($match[0], $this->encoding);
75
                }
76
                else
77
                {
78
                    return $marchToUpper;
79
                }
80
            },
81
            $this->scalarString
82
        ));
83
    }
84
}
85