A collection of PHP helper functions to be used in conditional logic within projects.
To use these conditional helpers, simply install the package via Composer:
composer require garydavisonos/conditional-helpers
The following helper functions are available:
isArrayHasLength($array): Checks if an array has a length greater than zero.
isStringHasLength($string): Checks if a string has a length greater than zero.
isBooleanTrue($boolean): Checks if a value is a boolean true.
isBooleanFalse($boolean): Checks if a value is a boolean false.
Check if an array has a length greater than zero:
use GaryDavisonOs\ConditionalHelpers\ConditionalHelpers as Helpers;
$array = [1, 2, 3];
$result = Helpers::isArrayHasLength($array); // Returns true
Check if a string has a length greater than zero
use GaryDavisonOs\ConditionalHelpers\ConditionalHelpers as Helpers;
$string = "Hello, World!";
$result = Helpers::isStringHasLength($string); // Returns true
Check if a value is a boolean true
use GaryDavisonOs\ConditionalHelpers\ConditionalHelpers as Helpers;
$boolean = true;
$result = Helpers::isBooleanTrue($boolean); // Returns true
Contributions are welcome! If you'd like to add a new helper function or improve an existing one, please submit a pull request.
This package is licensed under the MIT License.