Formatter
extends BaseFormatter
in package
Table of Contents
Constants
- QUOTE_REPLACEMENT = ""
- SECTION_SPLIT = '/;(?=(?:[^"]*"[^"]*")*[^"]*\Z)/miu'
- Matches any ; symbol that isn't enclosed in quotes, for a "section" split.
- SYMBOL_AT = '/@(?=(?:[^"]*"[^"]*")*[^"]*\Z)/miu'
- Matches any @ symbol that isn't enclosed in quotes.
Methods
- toFormattedString() : string
- Convert a value in a pre-defined format to a PHP string.
- adjustSeparators() : string
- stripQuotes() : string
- splitFormatComparison() : bool
- splitFormatForSectionSelection() : array<string|int, mixed>
Constants
QUOTE_REPLACEMENT
private
mixed
QUOTE_REPLACEMENT
= ""
SECTION_SPLIT
Matches any ; symbol that isn't enclosed in quotes, for a "section" split.
private
mixed
SECTION_SPLIT
= '/;(?=(?:[^"]*"[^"]*")*[^"]*\Z)/miu'
SYMBOL_AT
Matches any @ symbol that isn't enclosed in quotes.
private
mixed
SYMBOL_AT
= '/@(?=(?:[^"]*"[^"]*")*[^"]*\Z)/miu'
Methods
toFormattedString()
Convert a value in a pre-defined format to a PHP string.
public
static toFormattedString(null|array<string|int, mixed>|bool|float|int|RichText|string $value, string $format[, array<string|int, mixed>|null $callBack = null ]) : string
Parameters
- $value : null|array<string|int, mixed>|bool|float|int|RichText|string
-
Value to format
- $format : string
-
Format code: see = self::FORMAT_* for predefined values; or can be any valid MS Excel custom format string
- $callBack : array<string|int, mixed>|null = null
-
Callback function for additional formatting of string
Return values
string —Formatted string
adjustSeparators()
protected
static adjustSeparators(string $value) : string
Parameters
- $value : string
Return values
stringstripQuotes()
protected
static stripQuotes(string $format) : string
Parameters
- $format : string
Return values
stringsplitFormatComparison()
private
static splitFormatComparison(mixed $value, string|null $condition, mixed $comparisonValue, string $defaultCondition, mixed $defaultComparisonValue) : bool
Parameters
- $value : mixed
- $condition : string|null
- $comparisonValue : mixed
- $defaultCondition : string
- $defaultComparisonValue : mixed
Return values
boolsplitFormatForSectionSelection()
private
static splitFormatForSectionSelection(array<string|int, mixed> $sections, float|int|numeric-string $value) : array<string|int, mixed>
Parameters
- $sections : array<string|int, mixed>
- $value : float|int|numeric-string
-
value to be formatted