wpdatatables
/
lib
/
phpoffice
/
phpspreadsheet
/
src
/
PhpSpreadsheet
/
Calculation
/
TextData
/
Trim.php
Trim.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/TextData/Trim.php
| 1 | <?php |
| 2 | |
| 3 | namespace PhpOffice\PhpSpreadsheet\Calculation\TextData; |
| 4 | |
| 5 | use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; |
| 6 | |
| 7 | class Trim |
| 8 | { |
| 9 | use ArrayEnabled; |
| 10 | |
| 11 | /** |
| 12 | * CLEAN. |
| 13 | * |
| 14 | * @param mixed $stringValue String Value to check |
| 15 | * Or can be an array of values |
| 16 | * |
| 17 | * @return array|string |
| 18 | * If an array of values is passed as the argument, then the returned result will also be an array |
| 19 | * with the same dimensions |
| 20 | */ |
| 21 | public static function nonPrintable($stringValue = '') |
| 22 | { |
| 23 | if (is_array($stringValue)) { |
| 24 | return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $stringValue); |
| 25 | } |
| 26 | |
| 27 | $stringValue = Helpers::extractString($stringValue); |
| 28 | |
| 29 | return (string) preg_replace('/[\x00-\x1f]/', '', "$stringValue"); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * TRIM. |
| 34 | * |
| 35 | * @param mixed $stringValue String Value to check |
| 36 | * Or can be an array of values |
| 37 | * |
| 38 | * @return array|string |
| 39 | * If an array of values is passed as the argument, then the returned result will also be an array |
| 40 | * with the same dimensions |
| 41 | */ |
| 42 | public static function spaces($stringValue = '') |
| 43 | { |
| 44 | if (is_array($stringValue)) { |
| 45 | return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $stringValue); |
| 46 | } |
| 47 | |
| 48 | $stringValue = Helpers::extractString($stringValue); |
| 49 | |
| 50 | return trim(preg_replace('/ +/', ' ', trim("$stringValue", ' ')) ?? '', ' '); |
| 51 | } |
| 52 | } |
| 53 |