Number
- Type
- Class
- Namespace
- craft\helpers
- Inherits
- craft\helpers\Number
- Since
- 3.0.0
Class Number
View source (opens new window)
# Public Methods
Method | Description |
---|---|
isInt() | Returns whether the given number lacks decimal points when typecast to a float. |
isIntOrFloat() | Returns whether the given value is an int or float, or a string that represents an int or float. |
lowerAlpha() | Returns the lowercase alphabetic version of a number |
lowerRoman() | Returns the lowercase roman numeral version of a number |
makeNumeric() | Returns the numeric value of a variable. |
toIntOrFloat() | Typecasts the given number into an integer or a float. |
upperAlpha() | Returns the uppercase alphabetic version of a number |
upperRoman() | Returns the uppercase roman numeral version of a number |
word() | Returns the "word" version of a number |
# isInt()
- Since
- 4.0.0
Returns whether the given number lacks decimal points when typecast to a float.
View source (opens new window)
Arguments
Returns
Throws
- yii\base\InvalidArgumentException (opens new window)
if $value isn’t numeric
# isIntOrFloat()
- Since
- 4.0.5
Returns whether the given value is an int or float, or a string that represents an int or float.
View source (opens new window)
Arguments
$value
(mixed
)
Returns
# lowerAlpha()
Returns the lowercase alphabetic version of a number
View source (opens new window)
Arguments
$num
(integer (opens new window)) – The number
Returns
string (opens new window) – The alphabetic version of the number
# lowerRoman()
Returns the lowercase roman numeral version of a number
View source (opens new window)
Arguments
$num
(integer (opens new window)) – The number
Returns
string (opens new window) – The roman numeral version of the number
# makeNumeric()
Returns the numeric value of a variable.
If the variable is an object with a __toString() method, the numeric value of its string representation will be returned.
View source (opens new window)
Arguments
$var
(mixed
)
Returns
float (opens new window), integer (opens new window), string (opens new window)
# toIntOrFloat()
- Since
- 4.0.0
Typecasts the given number into an integer or a float.
View source (opens new window)
Arguments
Returns
integer (opens new window), float (opens new window)
Throws
- yii\base\InvalidArgumentException (opens new window)
if $value isn’t numeric
# upperAlpha()
Returns the uppercase alphabetic version of a number
View source (opens new window)
Arguments
$num
(integer (opens new window)) – The number
Returns
string (opens new window) – The alphabetic version of the number
# upperRoman()
Returns the uppercase roman numeral version of a number
View source (opens new window)
Arguments
$num
(integer (opens new window)) – The number
Returns
string (opens new window) – The roman numeral version of the number
# word()
Returns the "word" version of a number
View source (opens new window)
Arguments
$num
(integer (opens new window)) – The number
Returns
string (opens new window) – The number word, or the original number if it's >= 10
← MoneyHelper Path →