You are here

StripWhitespaceTrait.php in Fences 8.2

File

tests/src/Traits/StripWhitespaceTrait.php
View source
<?php

namespace Drupal\Tests\fences\Traits;


/**
 * A trait to strip whitespace.
 */
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;
  }

}

Traits

Namesort descending Description
StripWhitespaceTrait A trait to strip whitespace.