Number
class Number (View source)
Traits
| Macroable |
Properties
| static protected array | $macros | The registered string macros. | from Macroable |
| static protected string | $locale | The current default locale. |
Methods
| static void | macro(string $name, object|callable $macro)
Register a custom macro. | from Macroable |
| static void | mixin(object $mixin, bool $replace = true)
Mix another object into the class. | from Macroable |
| static bool | hasMacro(string $name)
Checks if macro is registered. | from Macroable |
| static void | flushMacros()
Flush the existing macros. | from Macroable |
| static mixed | __callStatic(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| mixed | __call(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| 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 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 $offset = 1)
Split the given number into pairs of min/max values. | |
| 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 void | ensureIntlExtensionIsInstalled()
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 array pairs(int|float $to, int|float $by, int|float $offset = 1)
Split the given number into pairs of min/max values.
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.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Support/Number.html