Number
class Number (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
static protected string | $locale | The current default locale. |
|
static protected string | $currency | The current default currency. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Format the given number according to the current locale.
Spell out the given number in the given locale.
Convert the given number to ordinal form.
Convert the given number to its percentage equivalent.
Convert the given number to its currency equivalent.
Convert the given number to its file size equivalent.
Convert the number to its human-readable equivalent.
Convert the number to its human-readable equivalent.
Convert the number to its human-readable equivalent.
Clamp the given number between the given minimum and maximum.
Split the given number into pairs of min/max values.
Remove any trailing zero digits after the decimal point of the given number.
Execute the given callback using the given locale.
Execute the given callback using the given currency.
Set the default locale.
Set the default currency.
Get the default locale.
Get the default currency.
Ensure the "intl" PHP extension is installed.
Details
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool
hasMacro(string $name)
Checks if macro is registered.
static void
flushMacros()
Flush the existing macros.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
static string|false
format(int|float $number, int|null $precision = null, int|null $maxPrecision = null, string|null $locale = null)
Format the given number according to the current locale.
static string
spell(int|float $number, string|null $locale = null, int|null $after = null, int|null $until = null)
Spell out the given number in the given locale.
static string
ordinal(int|float $number, string|null $locale = null)
Convert the given number to ordinal form.
static string|false
percentage(int|float $number, int $precision = 0, int|null $maxPrecision = null, string|null $locale = null)
Convert the given number to its percentage equivalent.
static string|false
currency(int|float $number, string $in = '', string|null $locale = null)
Convert the given number to its currency equivalent.
static string
fileSize(int|float $bytes, int $precision = 0, int|null $maxPrecision = null)
Convert the given number to its file size equivalent.
static bool|string
abbreviate(int|float $number, int $precision = 0, int|null $maxPrecision = null)
Convert the number to its human-readable equivalent.
static false|string
forHumans(int|float $number, int $precision = 0, int|null $maxPrecision = null, bool $abbreviate = false)
Convert the number to its human-readable equivalent.
static protected string|false
summarize(int|float $number, int $precision = 0, int|null $maxPrecision = null, array $units = [])
Convert the number to its human-readable equivalent.
static int|float
clamp(int|float $number, int|float $min, int|float $max)
Clamp the given number between the given minimum and maximum.
static array
pairs(int|float $to, int|float $by, int|float $start = 0, int|float $offset = 1)
Split the given number into pairs of min/max values.
static int|float
trim(int|float $number)
Remove any trailing zero digits after the decimal point of the given number.
static mixed
withLocale(string $locale, callable $callback)
Execute the given callback using the given locale.
static mixed
withCurrency(string $currency, callable $callback)
Execute the given callback using the given currency.
static void
useLocale(string $locale)
Set the default locale.
static void
useCurrency(string $currency)
Set the default currency.
static string
defaultLocale()
Get the default locale.
static string
defaultCurrency()
Get the default currency.
static protected void
ensureIntlExtensionIsInstalled()
Ensure the "intl" PHP extension is installed.