Skip to content

Commit b6baaab

Browse files
author
Wazabii
committed
Add whitespace method
1 parent 501c7ba commit b6baaab

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Format/Str.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,26 @@ public function decode(?int $flag = ENT_QUOTES): self
136136
}
137137

138138
/**
139-
* Clears soft breaks
139+
* Clears soft breaks incl.:
140+
* line breaks (\n), carriage returns (\r), form feed (\f), and vertical tab (\v).
140141
* @return self
141142
*/
142143
public function clearBreaks(): self
143144
{
145+
144146
$this->value = preg_replace('/(\v|\s)+/', ' ', $this->strVal());
145-
return $this;
147+
return $this->trim();
148+
}
149+
150+
/**
151+
* Clear all white spaces characters incl.:
152+
* spaces, tabs, newline characters, carriage returns, and form feed characters
153+
* @return self
154+
*/
155+
public function clearWhitespace(): self
156+
{
157+
$this->value = preg_replace('/\s+/', ' ', $this->strVal());
158+
return $this->trim();
146159
}
147160

148161
/**

0 commit comments

Comments
 (0)