ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Trim.php
Go to the documentation of this file.
1<?php
2
4
7
8class Trim
9{
10 private static $invalidChars;
11
19 public static function nonPrintable($stringValue = '')
20 {
21 $stringValue = Functions::flattenSingleValue($stringValue);
22
23 if (is_bool($stringValue)) {
24 return ($stringValue) ? Calculation::getTRUE() : Calculation::getFALSE();
25 }
26
27 if (self::$invalidChars === null) {
28 self::$invalidChars = range(chr(0), chr(31));
29 }
30
31 if (is_string($stringValue) || is_numeric($stringValue)) {
32 return str_replace(self::$invalidChars, '', trim($stringValue, "\x00..\x1F"));
33 }
34
35 return null;
36 }
37
45 public static function spaces($stringValue = '')
46 {
47 $stringValue = Functions::flattenSingleValue($stringValue);
48 if (is_bool($stringValue)) {
49 return ($stringValue) ? Calculation::getTRUE() : Calculation::getFALSE();
50 }
51
52 if (is_string($stringValue) || is_numeric($stringValue)) {
53 return trim(preg_replace('/ +/', ' ', trim($stringValue, ' ')), ' ');
54 }
55
56 return null;
57 }
58}
An exception for terminatinating execution or to throw for unit testing.
static getTRUE()
Return the locale-specific translation of TRUE.
static getFALSE()
Return the locale-specific translation of FALSE.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
Definition: Functions.php:649
static spaces($stringValue='')
TRIMSPACES.
Definition: Trim.php:45
static nonPrintable($stringValue='')
TRIMNONPRINTABLE.
Definition: Trim.php:19