1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-09-01 01:01:46 +02:00

Added toBoolean

This commit is contained in:
Daniel St. Jules
2015-07-23 23:40:21 -07:00
parent 6b74918cc9
commit bded15d683
3 changed files with 82 additions and 0 deletions

View File

@@ -74,6 +74,7 @@ S::create('string')->toTitleCase()->ensureRight('y') == 'Stringy'
* [tidy](#tidy)
* [titleize](#titleize-array-ignore)
* [toAscii](#toascii)
* [toBoolean](#toboolean)
* [toLowerCase](#tolowercase)
* [toSpaces](#tospaces-tablength--4-)
* [toTabs](#totabs-tablength--4-)
@@ -733,6 +734,20 @@ unless instructed otherwise.
S::create('fòô bàř')->toAscii(); // 'foo bar'
```
##### toBoolean()
Returns a boolean representation of the given logical string value.
For example, 'true', '1', 'on' and 'yes' will return true. 'false', '0',
'off', and 'no' will return false. In all instances, case is ignored.
For other numeric strings, their sign will determine the return value.
In addition, blank strings consisting of only whitespace will return
false. For all other strings, the return value is a result of a
boolean cast.
```php
S::create('OFF')->toBoolean(); // false
```
##### toLowerCase()
Converts all characters in the string to lowercase. An alias for PHP's