Passed
Push — master ( dbfdbf...85c67d )
by Alex
06:28
created

XMLStringTrait::replaceString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\StringTraits;
4
5
trait XMLStringTrait
6
{
7
    /**
8
     * @param string $string
9
     * @return mixed
10
     */
11
    public function preserveString($string)
12
    {
13
        return $string;
14
    }
15
16
    /**
17
     * @param string $string
18
     * @return mixed
19
     */
20
    public function replaceString($string)
21
    {
22
        $string = preg_replace('/\s/', ' ', $string);
23
        return $string;
24
    }
25
26
    /**
27
     * @param string $string
28
     * @return mixed
29
     */
30
    public function collapseString($string)
31
    {
32
        $string = $this->replaceString(trim($string));
33
        $string = preg_replace('/[ ]+/', ' ', $string);
34
        return $string;
35
    }
36
}