garydavisonos/conditional-helpers

A collection of helper functions to be used in conditional logic

2.0.1 2025-01-25 11:17 UTC

This package is auto-updated.

Last update: 2025-02-25 11:57:13 UTC


README

A collection of PHP helper functions to be used in conditional logic within projects.

Version License Dependencies

Table of Contents

Installation

To use these conditional helpers, simply install the package via Composer:

composer require garydavisonos/conditional-helpers

Functions

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.

Usage

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

Contributing

Contributions are welcome! If you'd like to add a new helper function or improve an existing one, please submit a pull request.

License

This package is licensed under the MIT License.