You are here

trait StripWhitespaceTrait in Fences 8.2

A trait to strip whitespace.

Hierarchy

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\Traits
View 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

Namesort descending Modifiers Type Description Overrides
StripWhitespaceTrait::stripWhitespace protected function Remove HTML whitespace from a string.