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. |
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.
Execute the given callback using the given locale.
Set the default locale.
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 = 'USD', 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 bool|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 mixed
withLocale(string $locale, callable $callback)
Execute the given callback using the given locale.
static void
useLocale(string $locale)
Set the default locale.
static protected void
ensureIntlExtensionIsInstalled()
Ensure the "intl" PHP extension is installed.