Completed
Pull Request — master (#39)
by Andre
01:07
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
function strlen(string $string): int
6
{
7
    return \mb_strlen($string, 'UTF-8');
8
}
9
10
function tcword(string $string): string
11
{
12
    return \mb_convert_case($string, MB_CASE_TITLE, 'UTF-8');
13
}
14
15
function characters(string $string): array
16
{
17
    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...
18
}
19
20
function substr(string $string, int $start, int $length = null): string
21
{
22
    return \mb_substr($string, $start, $length, 'UTF-8');
23
}
24