Is::toggle()
Checks for valid boolean.
Table of Contents
Description
Is::toggle(mixed $value): bool;This method checks that the input provided is a literal boolean or a valid boolean string.
Example
if (Is::toggle(false)) {
// …
}Validation
Below are examples of input data along with the validation results:
| Test | Result |
|---|---|
'0' | true |
'1' | true |
'FALSE' | true |
'False' | true |
'NO' | true |
'No' | true |
'OFF' | true |
'ON' | true |
'Off' | true |
'On' | true |
'TRUE' | true |
'True' | true |
'YES' | true |
'Yes' | true |
'false' | true |
'no' | true |
'off' | true |
'on' | true |
'true' | true |
'yes' | true |
0 | true |
1 | true |
false | true |
true | true |
' True ' | true |
'TruE' | true |
'True asdf' | false |
Is::IP()
Checks for valid IP address.
Is::JSON()
Checks for valid JSON string.
Is::URL()
Checks for valid URL address.
Is::_()
Creates a virtual method.
Is::__callStatic()
Calls the virtual method that has been created.
Is::email()
Checks for valid email address.
Is::file()
Checks if current input is a valid file path.
Is::folder()
Checks if current input is a valid folder path.
Is::path()
Checks if current input is a valid path.
Is::serial()
Checks for valid serialized string.
Is::toggle()
Checks for valid boolean.
Is::void()
Checks for empty string, array and object.