PHPackages                             humans/when - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. humans/when

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

humans/when
===========

A global helper for if else statements

1.0.0(5y ago)014.8k↓28.6%MITPHP

Since Mar 9Pushed 5y ago2 watchersCompare

[ Source](https://github.com/humans/when)[ Packagist](https://packagist.org/packages/humans/when)[ RSS](/packages/humans-when/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

When
====

[](#when)

Installation
------------

[](#installation)

```
composer require humans/when
```

Usage
-----

[](#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

[](#comparison)

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

### Proxy

[](#proxy)

Proxies methods

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

Proxies properties

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

Global Methods
--------------

[](#global-methods)

```
when();

unless();
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1897d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21359371?v=4)[Humans](/maintainers/humans)[@humans](https://github.com/humans)

---

Top Contributors

[![jaggy](https://avatars.githubusercontent.com/u/1993075?v=4)](https://github.com/jaggy "jaggy (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/humans-when/health.svg)

```
[![Health](https://phpackages.com/badges/humans-when/health.svg)](https://phpackages.com/packages/humans-when)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
