Sanitizer::removeFirstAndLastCharacters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
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