You are here

trait StripWhitespaceTrait in Video Embed Field 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/StripWhitespaceTrait.php \Drupal\Tests\video_embed_field\Kernel\StripWhitespaceTrait

Strip whitespace.

Hierarchy

File

tests/src/Kernel/StripWhitespaceTrait.php, line 8

Namespace

Drupal\Tests\video_embed_field\Kernel
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.