Completed
Pull Request — master (#39)
by Andre
01:05
created

string_functions_mbstring.php ➔ tcword()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TheIconic\NameParser;
4
5
if (!function_exists('TheIconic\NameParser\strlen')) {
6
    function strlen(string $string): int
7
    {
8
        return \mb_strlen($string, 'UTF-8');
9
    }
10
}
11
12
if (!function_exists('TheIconic\NameParser\tcword')) {
13
    function tcword(string $string): string
14
    {
15
        return \mb_convert_case($string, MB_CASE_TITLE, 'UTF-8');
16
    }
17
}
18
19
if (!function_exists('TheIconic\NameParser\characters')) {
20
    function characters(string $string): array
21
    {
22
        return $charactersAsArray = \preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
0 ignored issues
show
Unused Code introduced by
$charactersAsArray is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
23
    }
24
}
25
26
if (!function_exists('TheIconic\NameParser\substr')) {
27
    function substr(string $string, int $start, int $length = null): string
28
    {
29
        return \mb_substr($string, $start, $length, 'UTF-8');
30
    }
31
}
32