trait StripWhitespaceTrait in Fences 8.2
A trait to strip whitespace.
Hierarchy
- trait \Drupal\Tests\fences\Traits\StripWhitespaceTrait
2 files declare their use of StripWhitespaceTrait
- FieldOutputTest.php in tests/
src/ Kernel/ FieldOutputTest.php - IntegrationTest.php in tests/
src/ FunctionalJavascript/ IntegrationTest.php
File
- tests/
src/ Traits/ StripWhitespaceTrait.php, line 8
Namespace
Drupal\Tests\fences\TraitsView source
trait StripWhitespaceTrait {
/**
* Remove HTML whitespace from a string.
*
* @param string $string
* The input string.
*
* @return string
* The whitespace cleaned string.
*/
protected function stripWhitespace($string) {
$no_whitespace = preg_replace('/\\s{2,}/', '', $string);
$no_whitespace = str_replace("\n", '', $no_whitespace);
return $no_whitespace;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StripWhitespaceTrait:: |
protected | function | Remove HTML whitespace from a string. |