@@ 25-42 (lines=18) @@ | ||
22 | * |
|
23 | * @return static String without the prefix $substring. |
|
24 | */ |
|
25 | public function removeLeft($substring) |
|
26 | { |
|
27 | if ($this->startsWith($substring)) |
|
28 | { |
|
29 | return $this->newSelf |
|
30 | ( |
|
31 | UTF8::substr |
|
32 | ( |
|
33 | $this->scalarString, |
|
34 | UTF8::strlen($substring, $this->encoding), |
|
35 | null, |
|
36 | $this->encoding |
|
37 | ) |
|
38 | ); |
|
39 | } |
|
40 | ||
41 | return $this; |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Returns a new string with the suffix $substring removed, if present. |
|
@@ 51-68 (lines=18) @@ | ||
48 | * |
|
49 | * @return static String without the suffix $substring. |
|
50 | */ |
|
51 | public function removeRight($substring) |
|
52 | { |
|
53 | if ($this->endsWith($substring)) |
|
54 | { |
|
55 | return $this->newSelf |
|
56 | ( |
|
57 | UTF8::substr |
|
58 | ( |
|
59 | $this->scalarString, |
|
60 | 0, |
|
61 | $this->getLength() - UTF8::strlen($substring, $this->encoding), |
|
62 | $this->encoding |
|
63 | ) |
|
64 | ); |
|
65 | } |
|
66 | ||
67 | return $this; |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Trims and replaces consecutive whitespace characters with a single space. |