PHPackages                             djthossi/ensure - 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. djthossi/ensure

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

djthossi/ensure
===============

Some PHP Traits for ensuring values

1.2.0(9y ago)12.8k[2 issues](https://github.com/DjThossi/Ensure/issues)1MITPHPPHP &gt;=5.4

Since Dec 29Pushed 9y ago3 watchersCompare

[ Source](https://github.com/DjThossi/Ensure)[ Packagist](https://packagist.org/packages/djthossi/ensure)[ RSS](/packages/djthossi-ensure/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (9)Used By (1)

Ensure
======

[](#ensure)

Some PHP Traits for ensuring values [![Build Status](https://camo.githubusercontent.com/6cf9c543614d91a3452667e5e9ca1f609f77162b80800f0e4be5b3f343c7f8ca/68747470733a2f2f7472617669732d63692e6f72672f446a54686f7373692f456e737572652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/DjThossi/Ensure)[![SensioLabsInsight](https://camo.githubusercontent.com/d2c7a9f2a297a5117808f9a7342ac0a02707f3db5550daaa42ed98daa6d60dab/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f63636165663736612d373235652d346231622d383932612d6333646434353730653632392f6d696e692e706e67)](https://insight.sensiolabs.com/projects/ccaef76a-725e-4b1b-892a-c3dd4570e629)[![Code Climate](https://camo.githubusercontent.com/820f4114c2e6532861da6eeda3d6c0dc9a8b25ad603b8ed303bbe0f4ec0c6fe8/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f446a54686f7373692f456e737572652f6261646765732f6770612e737667)](https://codeclimate.com/github/DjThossi/Ensure)[![Test Coverage](https://camo.githubusercontent.com/12f5a861b1a427e665e821e9b097684f737575474cf08ace71600d91dc573aab/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f446a54686f7373692f456e737572652f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/DjThossi/Ensure/coverage)

How it works
------------

[](#how-it-works)

The provided Ensure Traits will test if provided `$valueToTest` has expected value.

- If `$valueToTest` is valid nothing happens
- If `$valueToTest` is invalid `InvalidValueException` is thrown

Available Ensure Traits
-----------------------

[](#available-ensure-traits)

- EnsureIsBooleanTrait
- EnsureIsGreaterThanTrait
- EnsureIsIntegerTrait
- EnsureIsLowerThanTrait
- EnsureIsNotEmptyTrait
- EnsureIsStringTrait
- EnsureIsUrlTrait

How to install
--------------

[](#how-to-install)

You have several options to install this package

### Composer

[](#composer)

`composer require djthossi/ensure`

### Git

[](#git)

`git clone https://github.com/DjThossi/Ensure.git`

### Download

[](#download)

`https://github.com/DjThossi/Ensure/archive/master.zip`

Example
-------

[](#example)

```
class Message
{
    use EnsureIsStringTrait;

    const MESSAGE_IS_NOT_A_STRING = 1;

    /**
     * @param string $message
     */
    public function __construct($message)
    {
        $this->ensureIsString('Message', $message, self::MESSAGE_IS_NOT_A_STRING);
    }
}
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 95.3% 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 ~5 days

Total

7

Last Release

3442d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9482665?v=4)[Sebastian Thoss](/maintainers/DjThossi)[@DjThossi](https://github.com/DjThossi)

---

Top Contributors

[![DjThossi](https://avatars.githubusercontent.com/u/9482665?v=4)](https://github.com/DjThossi "DjThossi (41 commits)")[![zeka001](https://avatars.githubusercontent.com/u/12069332?v=4)](https://github.com/zeka001 "zeka001 (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/djthossi-ensure/health.svg)

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

###  Alternatives

[pressbooks/pressbooks-aldine

Aldine is the default theme for the home page of Pressbooks networks. It is named for the Aldine Press, founded by Aldus Manutius in 1494, who is regarded by many as the world’s first publisher.

114.5k](/packages/pressbooks-pressbooks-aldine)

PHPackages © 2026

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