PHPackages                             ismailocal/whenable - 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. ismailocal/whenable

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

ismailocal/whenable
===================

Php when, then, else pattern and whenable trait

00PHP

Since Aug 14Pushed 6y agoCompare

[ Source](https://github.com/ismailocal/whenable)[ Packagist](https://packagist.org/packages/ismailocal/whenable)[ RSS](/packages/ismailocal-whenable/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Whenable
========

[](#whenable)

User Class With WhenableTrait

```
class User{
    use \Ismailocal\Whenable\WhenableTrait;

    protected $id;
    protected $name;
    protected $active = true;

    public function __construct($id, $name)
    {
        $this->id = $id;
        $this->name = $name;
    }

    public function setPassive(){
      // Logic
    }
}
```

Example Usage

```
$user = new User(1, 'ismailocal');

$user->when(function (){
    return $this->active;
})->then(function(){
    $this->setPassive();
})->else(function(){
    log($this->name +' not active user!')
});
```

Example Usage Without Trait

```
$user = new User(1, 'ismailocal');

\Ismailocal\Whenable\Whenable::when(function () use($user){
    return $user->active;
})->then(function () use($user){
    $user->setPassive();
})->else(function () use($user){
    log($user->name +' not active user!')
});
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b0eabbcc98c72d62890f0e26e01d4f3055e65613c33232e4969e6df6788c91f?d=identicon)[ismailocal](/maintainers/ismailocal)

---

Top Contributors

[![ismailocal](https://avatars.githubusercontent.com/u/4483250?v=4)](https://github.com/ismailocal "ismailocal (5 commits)")

### Embed Badge

![Health badge](/badges/ismailocal-whenable/health.svg)

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

###  Alternatives

[sastrawi/sastrawi

PHP library for stemming Indonesian language (Bahasa Indonesia)

44075.7k4](/packages/sastrawi-sastrawi)

PHPackages © 2026

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