PHPackages                             cerealean/php-common-utilities - 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. cerealean/php-common-utilities

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

cerealean/php-common-utilities
==============================

Commonly used core PHP functionality improved upon and made for quick, easy use

1.0.2(11y ago)445.9k↓50%MITPHPPHP &gt;=5.3CI passing

Since Nov 13Pushed 11y ago1 watchersCompare

[ Source](https://github.com/cerealean/php-common-utilities)[ Packagist](https://packagist.org/packages/cerealean/php-common-utilities)[ RSS](/packages/cerealean-php-common-utilities/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (4)Used By (0)

php-common-utilities
====================

[](#php-common-utilities)

[![Build Status](https://camo.githubusercontent.com/3b9c27e3665dbe21d43401898f53d2050621b6fb3fb560c492e7298a4e19c329/68747470733a2f2f7472617669732d63692e6f72672f63657265616c65616e2f7068702d636f6d6d6f6e2d7574696c69746965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cerealean/php-common-utilities) [![Latest Stable Version](https://camo.githubusercontent.com/7552221c48e66d25daaa28c30d5dfac76e793dc6caa1dd2b3679d99cfe1c7dc3/68747470733a2f2f706f7365722e707567782e6f72672f63657265616c65616e2f7068702d636f6d6d6f6e2d7574696c69746965732f762f737461626c652e737667)](https://packagist.org/packages/cerealean/php-common-utilities) [![Total Downloads](https://camo.githubusercontent.com/087e896b85fd15828f6398f3bfc2f56d6fe4a6971a130a9d91e626656fd98518/68747470733a2f2f706f7365722e707567782e6f72672f63657265616c65616e2f7068702d636f6d6d6f6e2d7574696c69746965732f646f776e6c6f6164732e737667)](https://packagist.org/packages/cerealean/php-common-utilities) [![License](https://camo.githubusercontent.com/cd8cf04880e3f3a1a7bbe5c11a2697c14078071f031950fd2d016c86c26e959e/68747470733a2f2f706f7365722e707567782e6f72672f63657265616c65616e2f7068702d636f6d6d6f6e2d7574696c69746965732f6c6963656e73652e737667)](https://packagist.org/packages/cerealean/php-common-utilities)[![Dependency Status](https://camo.githubusercontent.com/9a6e72532f319daa67986b60f58b2b091ee685b33dbeab088a9c415a16d61482/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3534656366343362373862343630356137353030303031312f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/54ecf43b78b4605a75000011)

This package uses a variadic wrapper functions for core PHP functionality to make calls to those functions easier, cleaner, and reduce duplication. Please see the examples below.

Author
------

[](#author)

- Michael Crawford
- github.com/cerealean

Installation Instructions
-------------------------

[](#installation-instructions)

\###Using Composer Simply add `cerealean/php-common-utilities : 1.0.*` to your composer.json file. For more information on composer, please go [here](https://getcomposer.org/).

\###Packagist You can view all of the versions of this package on Packagist [here](https://packagist.org/packages/cerealean/php-common-utilities).

Examples
--------

[](#examples)

\###Example using IsEmpty

Are you tired of writing code that looks like this?

```
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address = $_POST['address'];

if(!empty($first_name) && !empty($last_name) && !empty($address)){
/* do something */
}
```

Instead, using this package, you can write this:

```
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address = $_POST['address'];

if(IsEmpty::none($first_name, $last_name, $address)){
/* do something */
}
```

\###Example using IsString

Instead of writing this

```
/* Stuff done */

if(is_string($first_example) && is_string($second_example) && is_string('This is a string')){
/* Do more stuff */
}
```

Write this

```
/* Stuff done */

if(IsString::all($first_example, $second_example, 'This is a string')){
/* Do more stuff */
}
```

Variable Handling
-----------------

[](#variable-handling)

All variable handling classes, as seen above, follow the same interface. As such, they all have the following functions:

- any
    - Returns true if **any** of the parameters match what is being tested. Otherwise returns false.
    - `IsEmpty::any("I will return true", "");` returns true because of the second parameter
    - `IsEmpty::any("I will return false", "Not empty");` returns false because both are not empty
- none
    - Opposite of any
    - `IsEmpty::none("I will return false", "");` returns false because of the second parameter
    - `IsEmpty::none("I will return true", "Not empty");` returns true because both are not empty
- all
    - Returns true if **all** of the parameters match what is being tested. Otherwise returns false.
    - `IsEmpty::all("I will return true", "");` returns false because of the first parameter
    - `IsEmpty::all(array(), "");` returns true because both are empty
- value
    - Only accepts one parameter. A simple OOP wrapper for the core function. This is mostly useful in the instantiated version for testing (see below).
    - `IsEmpty::value('not empty');` returns false
    - `IsEmpty::value(0);` returns true

**Important Note:** All functions are variadic which means they can accept any number of parameters. For more information on variadic functions, please see [php.net](http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list).

Currently Supported Functionality
---------------------------------

[](#currently-supported-functionality)

*reminder that all below functionality implements the VariableHandling interface*

- IsArray
- IsBool
- IsCallable
- IsDeclared *(different name for [isset](http://php.net/manual/en/function.isset.php) in core functionality)*
- IsDouble
- IsEmpty
- IsFile
- IsFinite
- IsFloat
- IsInfinite
- IsInteger
- IsLong
- IsNotANumber
- IsNull
- IsNumeric
- IsObject
- IsReadable
- IsResource
- IsScalar
- IsString

Instantiated (Non-Static) Classes
---------------------------------

[](#instantiated-non-static-classes)

This package also has instantiated versions of every class. I am a firm believer in testing all code (although this package currently doesn't have many tests) and having instantiated versions of all classes can help in your testing. By using instantiated versions of this package in your code in place of the static versions, you can mock them out in testing.

\###Example using IsReadable:

It would be difficult to unit test a function where you are reading from a file using core functionality

```
/* Do stuff */

if(is_readable($first_file) && is_readable($second_file)){
/* do stuff */
}
```

Instead, if you use the instantiated version of IsReadable

```
/* Do stuff and instantiate IsReadable into $is_readable */

if($is_readable->all($first_file, $second_file)){
/* Do stuff */
}
```

You can stub out $is\_readable and control what it returns during unit testing. This is easiest to do using a Mocking/Stubbing framework.

**Note:** All instantiated classes are wrappers of the static classes. Calling a function from an instantiated class simply returns a call from its associated static class.

Final Notes
-----------

[](#final-notes)

If there are any questions or comments please let me know. If you have any suggested functionality for this package that is not already currently implemented, feel free to suggest it or make the addition into a merge request and I will review. This is my first major standalone Github package, so feedback is always welcome. Thanks!

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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 ~6 days

Total

3

Last Release

4193d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef18f6b55d80f4e63c2b463df7e76cf9d91a6ebeb4613656e9e1d517815230ad?d=identicon)[cerealean](/maintainers/cerealean)

---

Top Contributors

[![cerealean](https://avatars.githubusercontent.com/u/6100756?v=4)](https://github.com/cerealean "cerealean (37 commits)")

---

Tags

phputilitycommoncorewrapperutilitiesvariadicemptyfunctionality

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cerealean-php-common-utilities/health.svg)

```
[![Health](https://phpackages.com/badges/cerealean-php-common-utilities/health.svg)](https://phpackages.com/packages/cerealean-php-common-utilities)
```

PHPackages © 2026

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