Reference
PHP API
Every public class and method of mdgascar/malagasy-intl, by module. All classes live under the Mdgascar\MalagasyIntl namespace.
Ce contenu n’est pas encore disponible dans votre langue.
Everything is under the Mdgascar\MalagasyIntl namespace. Errors throw MalagasyIntlException; read $exception->errorCode (an ErrorCode), the same code in every language.
Number words
Section titled “Number words”| Method | Returns | Error codes |
|---|---|---|
NumberWords\NumberWords::spell(int|float|string $n, NumberSystem) |
string |
OUT_OF_RANGE, INVALID_FORMAT |
NumberWords\NumberWords::spellOrdinal(int|string $n, NumberSystem) |
string |
OUT_OF_RANGE, INVALID_FORMAT |
NumberWords\NumberWords::parse(string $words) |
ExactNumber |
INVALID_FORMAT, OUT_OF_RANGE |
NumberWords\NumberWords::safeParse(mixed $words) |
SafeParseResult<ExactNumber> |
never |
NumberWords\NumberWords::tryParse(mixed $words) |
?ExactNumber |
never |
ExactNumber->value() |
int|float |
PRECISION_LOSS |
ExactNumber->digits |
string |
never |
Enum: NumberWords\NumberSystem (Standard, Traditional).
| Method | Returns | Error codes |
|---|---|---|
PhoneNumber\PhoneNumber::parse(string $input) |
PhoneNumber |
INVALID_FORMAT, UNKNOWN_OPERATOR |
PhoneNumber\PhoneNumber::safeParse(mixed $input) |
SafeParseResult<PhoneNumber> |
never |
PhoneNumber\PhoneNumber::tryParse(mixed $input) |
?PhoneNumber |
never |
PhoneNumber\PhoneNumber::isValid(mixed $input) |
bool |
never |
$phone->format(PhoneNumberFormat $format) |
string |
never |
$phone->e164, $phone->nationalNumber |
string |
never |
$phone->operator |
Operator |
never |
$phone->type |
PhoneLineType |
never |
$phone->area |
?PhoneArea (name, province) |
never |
Enums: PhoneNumberFormat (E164, International, National), Operator (displayName()), PhoneLineType (Mobile, Fixed).
Ariary
Section titled “Ariary”| Method | Returns | Error codes |
|---|---|---|
Ariary\Ariary::fromInt(int $amount) |
Ariary |
OUT_OF_RANGE |
Ariary\Ariary::fromFloat(float $amount) |
Ariary |
OUT_OF_RANGE, INVALID_TYPE |
Ariary\Ariary::fromText(string $amount) |
Ariary |
INVALID_FORMAT |
Ariary\Ariary::parse(string $text, ?Grouping, DecimalSeparator) |
Ariary |
INVALID_FORMAT, INVALID_TYPE |
Ariary\Ariary::safeParse(mixed $text, …) |
SafeParseResult<Ariary> |
never |
Ariary\Ariary::tryParse(mixed $text, …) |
?Ariary |
never |
Ariary\Ariary::fromFmg(int|float|string $francs) |
Ariary |
OUT_OF_RANGE, INVALID_FORMAT |
Ariary\Ariary::formatFmg(int|float|string $francs, …) |
string |
OUT_OF_RANGE, INVALID_FORMAT |
$amount->format(Grouping, SymbolPosition, DecimalSeparator) |
string |
INVALID_TYPE |
$amount->spell(NumberSystem) |
string |
never |
$amount->amount() |
int|float |
PRECISION_LOSS |
$amount->digits |
string |
never |
$amount->toFmg() |
int|float |
PRECISION_LOSS |
$amount->toFmgDigits() |
string |
never |
Enums: Grouping (Space, Dot, Comma), DecimalSeparator (Comma, Dot), SymbolPosition (Before, After).
| Method | Returns | Error codes |
|---|---|---|
DateTime\MalagasyDate::fromString(string $isoDate) |
MalagasyDate |
INVALID_FORMAT, OUT_OF_RANGE |
DateTime\MalagasyDate::fromParts(int $year, int $month, int $day) |
MalagasyDate |
OUT_OF_RANGE |
DateTime\MalagasyDate::fromDateTime(DateTimeInterface $date) |
MalagasyDate |
OUT_OF_RANGE |
DateTime\MalagasyDate::parse(string $text, ?DateStyle) |
MalagasyDate |
INVALID_FORMAT, OUT_OF_RANGE |
DateTime\MalagasyDate::safeParse(mixed $text, ?DateStyle) |
SafeParseResult<MalagasyDate> |
never |
DateTime\MalagasyDate::tryParse(mixed $text, ?DateStyle) |
?MalagasyDate |
never |
DateTime\MalagasyDateTime::fromString(string $dateTime) |
MalagasyDateTime |
INVALID_FORMAT, OUT_OF_RANGE |
$dateTime->spell(DateStyle $style) |
string |
never |
$date->format(DateStyle $style) |
string |
never |
DateTime\MalagasyDate::monthName(int $month, NameWidth) |
string |
OUT_OF_RANGE |
DateTime\MalagasyDate::weekdayName(int $isoWeekday, NameWidth) |
string |
OUT_OF_RANGE |
Enums: DateStyle (Long, Full, Medium, Short, Numeric), NameWidth (Wide, Abbreviated).
$date->isoWeekday() returns the ISO weekday (Monday 1, Sunday 7).
Shared
Section titled “Shared”| Class | Purpose |
|---|---|
MalagasyIntlException |
Thrown on bad input; ->errorCode is an ErrorCode |
ErrorCode |
InvalidType, OutOfRange, InvalidFormat, UnknownOperator, PrecisionLoss |
SafeParseResult |
->success, ->data, ->error from every safeParse() |
ExactNumber |
A number read from text: ->digits, and value() when an int or float holds it exactly |
SpecVersion::VERSION |
The spec version this package implements |
Wrong argument types raise PHP’s own TypeError; the spec reports them as INVALID_TYPE.