Passed
Pull Request — newinternal (#556)
by Matthew
03:29
created

StringFunctions::upperCaseFirst()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca;
10
11
class StringFunctions
12
{
13
    /**
14
     * Make a string's first character uppercase
15
     *
16
     * @param string $string
17
     *
18
     * @return string
19
     */
20 1
    public function upperCaseFirst($string)
21
    {
22 1
        if (ord($string) < 128) {
23 1
            return ucfirst($string);
24
        }
25
        else {
26 1
            return mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
27
        }
28
    }
29
}
30