SummaryHelper
in package
Utility class to handle information display.
Table of Contents
Methods
- cleanOutString() : string
- Properly formats carriage returns in a string and remove leading spaces before them.
- formatFloat() : string
- Formats decimal numbers for display, by removing all excess digits after the fifth.
- formatForDisplay() : string
- Truncates line-items to the max width of their corresponding column.
- padString() : string
- Pads and add separators to a string for rst table items.
- escapeSpecialChars() : string|null
- Prepends carriage return, new line & tab symbols with a backslash in a string.
Methods
cleanOutString()
Properly formats carriage returns in a string and remove leading spaces before them.
public
static cleanOutString(string $inputString) : string
Parameters
- $inputString : string
-
String to clean.
Return values
stringformatFloat()
Formats decimal numbers for display, by removing all excess digits after the fifth.
public
static formatFloat(float|null $number) : string
Parameters
- $number : float|null
-
Number to parse.
Return values
string —Number as a valid float string.
formatForDisplay()
Truncates line-items to the max width of their corresponding column.
public
static formatForDisplay([string|bool|null $inputString = null ][, int|null $maxColSize = null ]) : string
Parameters
- $inputString : string|bool|null = null
-
String to check.
- $maxColSize : int|null = null
-
Maximum size for the current column, if it exists.
Return values
stringpadString()
Pads and add separators to a string for rst table items.
public
static padString(string $inputString, int $colSize[, string $separator = "|" ]) : string
Parameters
- $inputString : string
-
Input value, as an already printable string.
- $colSize : int
-
Column size assigned to the value.
- $separator : string = "|"
-
Optional custom separator for tables.
Return values
string —The string, with table separators.
escapeSpecialChars()
Prepends carriage return, new line & tab symbols with a backslash in a string.
private
static escapeSpecialChars(string|null $string) : string|null
Parameters
- $string : string|null
-
The string to fix.
Return values
string|null —The fixed string.