humans/when

A global helper for if else statements

1.0.0 2021-03-09 10:07 UTC

This package is auto-updated.

Last update: 2024-12-09 18:48:31 UTC


README

Installation

composer require humans/when

Usage

echo when(true)->return('is-open');
// "is-open"

echo when(false)->return('is-open'); // prints null
// null

echo when(false)->return('is-open')->else('is-closed');
// "is-closed"

Comparison

echo when(true)->is(false)->return('is true')->else('is false');

Proxy

Proxies methods

when($product)->isOutOfStock()->return('is out of stock');

Proxies properties

when($product)->is_available->return('is available');

Global Methods

when();

unless();