ValueFormatter
final readonly class \
Writes keys and values of normalized data: values as JSON, markers unquoted, keys as shell-quoted path segments that can be pasted back as arguments.
Internal
Table of Contents
Methods
- countResolvedLabels() : int
- escapeUnsafeCharacters() : string
- Replaces unsafe characters in text that is not JSON by \uXXXX, as JSON escapes them.
- inline() : StyledText
- A whole subtree on one line, as JSON with markers unquoted. Stops once the text is wider than $limit, so a preview of a large subtree doesn't encode all of it.
- isLeaf() : bool
- json() : string
- Pretty-printed JSON with unsafe characters escaped.
- keys() : StyledText
- quote() : string
- toPlainData() : mixed
- Normalized data as plain PHP data for JSON: markers and resolved labels become strings.
- value() : StyledText
- A single value: a scalar, a marker, a resolved label or an empty array.
Methods
countResolvedLabels()
public
countResolvedLabels(mixed $value) : int
Parameters
- $value : mixed
Return values
intescapeUnsafeCharacters()
Replaces unsafe characters in text that is not JSON by \uXXXX, as JSON escapes them.
public
escapeUnsafeCharacters(string $text) : string
Parameters
- $text : string
Return values
stringinline()
A whole subtree on one line, as JSON with markers unquoted. Stops once the text is wider than $limit, so a preview of a large subtree doesn't encode all of it.
public
inline(array $value[, int $limit = PHP_INT_MAX ]) : StyledText
Parameters
- $value : array
- $limit : int = PHP_INT_MAX
Return values
StyledTextisLeaf()
public
isLeaf(mixed $value) : bool
Parameters
- $value : mixed
Return values
booljson()
Pretty-printed JSON with unsafe characters escaped.
public
json(mixed $data) : string
Parameters
- $data : mixed
Return values
stringkeys()
public
keys(array<int, string|int> $keys) : StyledText
Parameters
- $keys : array<int, string|int>
Return values
StyledTextquote()
public
quote(string|int $segment) : string
Parameters
- $segment : string|int
Return values
stringtoPlainData()
Normalized data as plain PHP data for JSON: markers and resolved labels become strings.
public
toPlainData(mixed $value) : mixed
Parameters
- $value : mixed
value()
A single value: a scalar, a marker, a resolved label or an empty array.
public
value(mixed $value) : StyledText
Parameters
- $value : mixed