StringModifier::replaceLineBreaksWithString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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