Sanitizer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 35
ccs 7
cts 7
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A removeLastCharacter() 0 3 1
A removeFirstAndLastCharacters() 0 5 1
A removeFirstCharacter() 0 3 1
1
<?php
2
3
namespace String;
4
5
/**
6
 * String sanitizer class.
7
 *
8
 * @package String
9
 */
10
final class Sanitizer
11
{
12
    /**
13
     * Remove the first and last character of a string.
14
     *
15
     * @param string $value
16
     * @return string
17
     */
18 10
    public static function removeFirstAndLastCharacters(string $value) : string
19
    {
20 10
        $valueLength = mb_strlen($value);
21
22 10
        return mb_substr($value, 1, $valueLength - 2);
23
    }
24
25
    /**
26
     * Remove the first character of a string.
27
     *
28
     * @param string $value
29
     * @return string
30
     */
31 10
    public static function removeFirstCharacter(string $value) : string
32
    {
33 10
        return mb_substr($value, 1);
34
    }
35
36
    /**
37
     * Remove the last character of a string.
38
     *
39
     * @param string $value
40
     * @return string
41
     */
42 10
    public static function removeLastCharacter(string $value) : string
43
    {
44 10
        return mb_substr($value, 0, -1);
45
    }
46
}
47