waughj / test-hash-item
A collection o’ helper functions for testing properties o’ a hash item
Installs: 402
Dependents: 15
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.0
Requires (Dev)
This package is auto-updated.
Last update: 2025-03-05 08:31:38 UTC
README
A collection o’ helper functions for testing properties o’ a hash item.
There are 2 main types o’ functions:
- those that just test a boolean true / false for a condition, which all take in the arguments: $list, $key. All test if value exists ( if $list[ $key ] is set ).
- those that return $list[ $key ] if the condition is true & return given fallback if not, which all take in arguments: $list, $key, $fallback. $fallback can be any type o’ value & defaults to null if nothing is given for it.
Boolean functions:
- exists: only tests if value exists.
- isString
- isArray
- isNumeric
- isBool
- isObject
- isClass: this takes in $class, $list, $key as arguments ’stead. $class is the specific name o’ the class testing for, as opposed to isObject, which accepts any object type.
Getter functions: ( these are use the previous tests for determining whether to return $list[ $key ] or $fallback )
- getExists
- getString
- getArray
- getBool
- getObject
- getClass
Finally, there are generic test & testIs methods, which have a callable as the 1st argument.
Changelog
2.0.0
- Refactor to make class with static functions ’stead o’ just functions to make working with namespace easier.
1.1.0
- Add TestHashItemIsTrue Function
1.0.0
- Initial Stable Version