NumberParseResult
in package
FinalYes
Carries the outcome of parsing a localized number.
Table of Contents
Methods
- failure() : self
- Creates a failed parse result.
- failureReason() : NumberParseFailureReason|null
- Returns why the parse failed.
- form() : NumberForm|null
- Returns the parsed number form.
- invalidWord() : string|null
- Returns the invalid word associated with the failure.
- succeeded() : bool
- Returns whether the parse succeeded.
- success() : self
- Creates a successful parse result.
- value() : int|null
- Returns the parsed value.
Methods
failure()
Creates a failed parse result.
public
static failure(NumberParseFailureReason $reason[, string|null $word = null ]) : self
Parameters
- $reason : NumberParseFailureReason
-
Failure reason.
- $word : string|null = null
-
Invalid word associated with the failure.
Return values
self —Failed parse result.
failureReason()
Returns why the parse failed.
public
failureReason() : NumberParseFailureReason|null
Return values
NumberParseFailureReason|null —Failure reason, or null on success.
form()
Returns the parsed number form.
public
form() : NumberForm|null
Return values
NumberForm|null —Parsed number form, or null on failure.
invalidWord()
Returns the invalid word associated with the failure.
public
invalidWord() : string|null
Return values
string|null —Invalid word, or null when none was identified.
succeeded()
Returns whether the parse succeeded.
public
succeeded() : bool
Return values
bool —True when the parse succeeded.
success()
Creates a successful parse result.
public
static success(int $value, NumberForm $form) : self
Parameters
- $value : int
-
Parsed value.
- $form : NumberForm
-
Parsed number form.
Return values
self —Successful parse result.
value()
Returns the parsed value.
public
value() : int|null
Return values
int|null —Parsed value, or null on failure.