StringModifier   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
eloc 10
c 2
b 0
f 1
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A replaceLineBreaksWithString() 0 5 2
A replaceMultipleSpacesWithOne() 0 5 2
A stripWhitespace() 0 5 2
1
<?php declare(strict_types=1);
2
3
namespace Sprain\SwissQrBill\String;
4
5
/**
6
 * @internal
7
 */
8
final class StringModifier
9
{
10
    public static function replaceLineBreaksWithString(?string $string): string
11
    {
12
        return is_null($string)
13
            ? ''
14
            : str_replace(["\r", "\n"], ' ', $string);
15
    }
16
17
    public static function replaceMultipleSpacesWithOne(?string $string): string
18
    {
19
        return is_null($string)
20
            ? ''
21
            :  preg_replace('/ +/', ' ', $string);
22
    }
23
24
    public static function stripWhitespace(?string $string): string
25
    {
26
        return is_null($string)
27
            ? ''
28
            : preg_replace('/\s+/', '', $string);
29
    }
30
}
31