class NFormat extends NumberFormatter

Number formatter for not following rules like Korean and Japanese.

Constants

private ORDINAL_DRIVER_PATH

Drivers path for the ordinals.

private CURRENCY_DRIVER_PATH

Properties

static $locale

Default locale name.

static $currency

Default ISO 4217 code aka currency code.

Methods

static string
spellOut(int $number)

Wrapper for NumberFormatter::format($locale, NumberFormatter::SPELLOUT).

static string
ordinalSpellOut(int $number)

Spell out ordinals for specific regions.

static string
currency(int|float|null $number, string $zero = '0')

Wrapper for NumberFormatter::format($locale, NumberFormatter::CURRENCY).

static string
currencySpellOut(int $number)

Spell out currency ordinals for specific regions.

static string
percent(int $number)

Wrapper for NumberFormatter::format($locale, NumberFormatter::PERCENT_SYMBOL).

static string
rawPercent(int $number)

Wrapper for NumberFormatter::format($locale, NumberFormatter::PERCENT_SYMBOL).

static string
decimal(int|float|null $number, string $zero = '0')

Wrapper for NumberFormatter::format($locale, NumberFormatter::DECIMAL).

Details

at line 41
static string spellOut(int $number)

Wrapper for NumberFormatter::format($locale, NumberFormatter::SPELLOUT).

Parameters

int $number

Number not to be formatted.

Return Value

string

Formatted number

Examples

NFormat::spellOut(5);
//=> 오

at line 58
static string ordinalSpellOut(int $number)

Spell out ordinals for specific regions.

Parameters

int $number

Number not to be formatted.

Return Value

string

Spell out ordinal.

Examples

NFormat::spellOut(10);
//=> 열번째

at line 80
static string currency(int|float|null $number, string $zero = '0')

Wrapper for NumberFormatter::format($locale, NumberFormatter::CURRENCY).

Parameters

int|float|null $number

Number not to be formatted

string $zero

If $number is 0, $zero will be returned.

Return Value

string

Examples

NFormat::currency(358762);
//=> ₩358,762

at line 101
static string currencySpellOut(int $number)

Spell out currency ordinals for specific regions.

Parameters

int $number

Number not to be formatted.

Return Value

string

Spell out currency ordinal.

Examples

NFormat::spellOut(12346);
//=> 12,346원

at line 134
static string percent(int $number)

Wrapper for NumberFormatter::format($locale, NumberFormatter::PERCENT_SYMBOL).

Parameters

int $number

Number not to be formatted

Return Value

string

Examples

NFormat::percent(12346);
//=> 1,234,600%

at line 150
static string rawPercent(int $number)

Wrapper for NumberFormatter::format($locale, NumberFormatter::PERCENT_SYMBOL).

Parameters

int $number

Number not to be formatted

Return Value

string

Examples

NFormat::percent(12346);
//=> 12,346%

at line 167
static string decimal(int|float|null $number, string $zero = '0')

Wrapper for NumberFormatter::format($locale, NumberFormatter::DECIMAL).

Parameters

int|float|null $number

Number not to be formatted

string $zero

If $number is 0, $zero will be returned.

Return Value

string

Examples

NFormat::decimal(358762);
//=> 358,762