Passed
Push — master ( 903b32...e503ad )
by Manuel
06:03
created

StringModifier   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 15
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A replaceLineBreaksWithString() 0 3 1
A replaceMultipleSpacesWithOne() 0 3 1
A stripWhitespace() 0 3 1
1
<?php
2
3
namespace Sprain\SwissQrBill\String;
4
5
class StringModifier
6
{
7
    public static function replaceLineBreaksWithString(?string $string): string
8
    {
9
        return str_replace(array("\r", "\n"), ' ', $string);
10
    }
11
12
    public static function replaceMultipleSpacesWithOne(?string $string): string
13
    {
14
        return preg_replace('/ +/', ' ', $string);
15
    }
16
17
    public static function stripWhitespace(?string $string): string
18
    {
19
        return preg_replace('/\s+/', '', $string);
20
    }
21
}
22