PHPackages                             carlosgoce/expressive - 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. carlosgoce/expressive

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

carlosgoce/expressive
=====================

Adds syntactical sugar to your conditional checks, arrays and more

1.0.3(11y ago)122MITPHPPHP &gt;=5.4

Since Oct 2Pushed 11y ago1 watchersCompare

[ Source](https://github.com/carlosgoce/expressive)[ Packagist](https://packagist.org/packages/carlosgoce/expressive)[ RSS](/packages/carlosgoce-expressive/feed)WikiDiscussions master Synced today

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

Expressive
==========

[](#expressive)

Adds syntactical sugar to your conditional checks, arrays and more.

[![Build Status](https://camo.githubusercontent.com/23548dd1079856b84a3068838f62c597519c9156a944418f35b2d24390c0bf35/68747470733a2f2f7472617669732d63692e6f72672f6361726c6f73676f63652f657870726573736976652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/carlosgoce/expressive)

Notes
-----

[](#notes)

- Like methods use == comparison instead of ===
- You can make your method call in static or non static way
- If a method is not found an UndefinedMethodException will be throwed

#### CarlosGoce\\Expressive\\Is

[](#carlosgoceexpressiveis)

```
Is::true($value);
Is::false($value);
Is::equalTo($expected, $value);
Is::like($expected, $value);
Is::void($value);
Is::null($value);
Is::inArray($needle, array $haystack);
Is::number($number);
Is::numeric($number);
Is::file($file);
```

#### CarlosGoce\\Expressive\\Not

[](#carlosgoceexpressivenot)

```
Not::true($value);
Not::false($value);
Not::equalTo($expected, $value);
Not::like($expected, $value);
Not::void($value);
Not::null($value);
Not::inArray($needle, array $haystack);
Not::number($number);
Not::numeric($number);
Not::file($file);
```

#### CarlosGoce\\Expressive\\Raise

[](#carlosgoceexpressiveraise)

```
Raise::when($condition, \Exception $exception);
Raise::unless($condition, \Exception $exception);
```

#### CarlosGoce\\Expressive\\Execute

[](#carlosgoceexpressiveexecute)

```
//Executes a closure and returns its value
Execute::it(\Closure $callback);
Execute::when($condition, \Closure $callback);
Execute::unless($condition, \Closure $callback);
```

#### CarlosGoce\\Expressive\\ArrayTask

[](#carlosgoceexpressivearraytask)

```
ArrayTask::changeKeysCase(array $array, $case = CASE_LOWER);
ArrayTask::count(array $array);
ArrayTask::filter(array $array, \Closure $callback = null);
ArrayTask::keys(array $array);
ArrayTask::pluck(array $array, $key)
ArrayTask::size(array $array); //alias of count
ArrayTask::shuffle(array $array);
ArrayTask::values(array $array);
ArrayTask::walk(array $array, \Closure $function);
ArrayTask::merge(array $arrays);
ArrayTask::reverse(array $array, $preserveKeys = false);
```

#### Express Facade

[](#express-facade)

You can also use the express facade so you won't need to import all the classes. You can use it in a static way or as non static to easier mocking.

Examples:

```
Express::execute()->it($closure);
Express::is()->file($file);
Express::not()->file($file);
Express::raise()->unless($condition, \Exception $exception);
Express::arrayTask()->keys($array);
```

Usage
-----

[](#usage)

Some real world examples:

```
//As static class
use CarlosGoce\Expressive\Is;
use CarlosGoce\Expressive\Raise;

class MyController
{
    public function myMethod()
    {
        //Easier to use
        Raise::when(Is::null($someValue), new \Exception('Some value is null') );
    }
}

//Using the express facade
use CarlosGoce\Expressive\Facade\Express;

class MyController
{
    public function myMethod()
    {
        //Easier to use and needs only one import but is more verbose
        Express::raise()->when(Express::Is()->null($someValue), new \Exception('Some value is null') );
    }
}

//As non static class injected with IOC
use CarlosGoce\Expressive\Is;
use CarlosGoce\Expressive\Raise;

class MyController
{
    protected $raise;
    protected $is;

    public function __construct(Raise $raise, Is $is)
    {
        $this->raise = $raise;
        $this->is = $is;
    }

    public function myMethod()
    {
        //Easier to test
        $this->raise->when($this->is->null($someValue), new \Exception('Some value is null') );
    }
}

//With the Express facade
use CarlosGoce\Expressive\Facade\Express;

class MyController
{
    protected $express;

    public function __construct(Express $express)
    {
        $this->express = $express;
    }

    public function myMethod()
    {
        //easier to test and use less imports but is more verbose
        $this->express->raise()->when( $this->express->is()->null($someValue), new \Exception('Some value is null') );
    }
}
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~0 days

Total

4

Last Release

4291d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2385242?v=4)[Carlos G.G.](/maintainers/carlosgoce)[@carlosgoce](https://github.com/carlosgoce)

---

Top Contributors

[![carlosgoce](https://avatars.githubusercontent.com/u/2385242?v=4)](https://github.com/carlosgoce "carlosgoce (44 commits)")

---

Tags

checksarrayssugarconditionalssyntactical

### Embed Badge

![Health badge](/badges/carlosgoce-expressive/health.svg)

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

###  Alternatives

[ilya/belt

A handful of tools for PHP developers.

71020.9k1](/packages/ilya-belt)[minwork/array

Pack of advanced array functions specifically tailored for: associative (assoc) array, multidimensional array, array of objects and handling nested array elements

66268.2k5](/packages/minwork-array)[sarhan/php-flatten

Flattens multidimensional arrays, traversables and vars into one dimensional array.

22185.1k1](/packages/sarhan-php-flatten)[sugarcrm/tidbit

Random data generator for Sugar

4525.0k](/packages/sugarcrm-tidbit)[dotty/dotty

Easy access to array data using dot notation

1293.8k1](/packages/dotty-dotty)[rotexsoft/versatile-collections

A collection package that can be extended to implement things such as a Dependency Injection Container, RecordSet objects for housing database records, a bag of http cookies, or technically any collection of items that can be looped over and whose items can each be accessed using array-access syntax or object property syntax.

186.1k1](/packages/rotexsoft-versatile-collections)

PHPackages © 2026

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