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

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

jimbo2150/php-utilities
=======================

Various utilities for PHP projects or libraries.

v1.0.0(1y ago)171Apache-2.0PHPPHP &gt;=8.1

Since Mar 1Pushed 11mo ago1 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

[![Version](https://camo.githubusercontent.com/93bcac6ca0970b92047afc4adb0cfc35edc628d58a8f63b698133ddd1021b539/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a696d626f323135302f7068702d7574696c6974696573)](https://camo.githubusercontent.com/93bcac6ca0970b92047afc4adb0cfc35edc628d58a8f63b698133ddd1021b539/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a696d626f323135302f7068702d7574696c6974696573)[![License](https://camo.githubusercontent.com/1061da8981a35fcd2a57ab69f0d70b79cc39c1e5ed8c66ee42d6ce8c7d17dc10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a696d626f323135302f7068702d7574696c6974696573)](https://camo.githubusercontent.com/1061da8981a35fcd2a57ab69f0d70b79cc39c1e5ed8c66ee42d6ce8c7d17dc10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a696d626f323135302f7068702d7574696c6974696573)[![PHP Required Version](https://camo.githubusercontent.com/58565f90eed340cbd609d3373eaf934dc25f0b067238325e2195e167d8f328b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6a696d626f323135302f7068702d7574696c69746965732f706870)](https://camo.githubusercontent.com/58565f90eed340cbd609d3373eaf934dc25f0b067238325e2195e167d8f328b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6a696d626f323135302f7068702d7574696c69746965732f706870)

PHP Utilities
=============

[](#php-utilities)

**A collection of useful PHP utility functions, interfaces, classes, traits, and enums to simplify common tasks and enhance your PHP projects.**

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [Changelog](#changelog)

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

[](#installation)

This library is distributed via [Composer](https://getcomposer.org/)'s [Packagist](https://packagist.org/) repository. To install it, run the following command in your project directory:

```
composer require jimbo2150/php-utilities
```

Usage
-----

[](#usage)

### Traitable

[](#traitable)

The `Traitable` trait provides a `hasTrait($traitName)` method that checks if the given trait is associated with the object instance. It works similar to how `instanceof` works with class hierarchy. It checks if the trait is directly connected to the class or if any of the class's ancestors have the given trait or if the class or class ancestors' traits uses the checked trait (e.g. it checks the trait hierarchy). It also caches the trait hierarchy as it traverses the tree so subsequent runs with classes that have those traits will perform faster and not have to traverse all or part of the hierarchy.

Here is an example of usage:

```
use Jimbo2150\PhpUtilities\Traitable;

trait resourceful {

}

trait streamable {
	// ...
}

trait writeable {
	use resourceful;
	use streamable;
	// ...
}

trait readable {
	use resourceful;
	use streamable;
	// ...
}

trait blankable {

}

class StringBuffer {
	use Traitable;
	use writeable;
	use readable;
	// ...
}

$string_stream = new StringBuffer();
$string_stream->hasTrait(resourceful::class); // true
$string_stream->hasTrait(readable::class); // true
$string_stream->hasTrait(blankable::class); // false
```

### Traits

[](#traits)

This helper class can be used instead of the `Traitable` trait to check if a class is an instance of a given trait. Using the same class/trait definition as above, you can run:

```
use Jimbo2150\PhpUtilities\Traits;

$string_stream = new StringBuffer();
Traits::instanceOf($string_stream, resourceful::class); // true
Traits::instanceOf($string_stream, readable::class); // true
Traits::instanceOf($string_stream, blankable::class); // false
```

Features
--------

[](#features)

Currently this library has a Traitable trait which allows you to check if the instance has an assigned trait to itself or any of it's ancestors (or any of the trait's traits). It's the equivalent of doing `$x instanceof TraitX` to check if an object is an instance of a given trait. There is also an associated `Trait` helper class with static functions which actually perform the trait check.

Feel free to suggest other utilities to add and I will take them under consideration - or submit a pull request with a new utility you would like to have added.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](/CHANGELOG.md).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance50

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

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

434d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97059717220eff8651a7de54dca6db5485e12a01d80ec3a35023ec8624d2710b?d=identicon)[jimbo2150](/maintainers/jimbo2150)

---

Top Contributors

[![jimbo2150](https://avatars.githubusercontent.com/u/25777094?v=4)](https://github.com/jimbo2150 "jimbo2150 (19 commits)")

---

Tags

libraryphpphp8traittraitsutilities

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[tzookb/tbmsg

users messaging system

10917.1k](/packages/tzookb-tbmsg)[cyber-duck/silverstripe-seo

A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content

4351.1k](/packages/cyber-duck-silverstripe-seo)[alexandresalome/assetic-extra-bundle

Extra feature for Assetic (asset directory)

1811.4k](/packages/alexandresalome-assetic-extra-bundle)

PHPackages © 2026

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