PHPackages                             anfischer/specification - 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. anfischer/specification

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

anfischer/specification
=======================

A package containing base classes to be used as a starting ground for implementing the Specification pattern in PHP.

v0.1.0(7y ago)17MITPHPPHP &gt;=7.1

Since Jun 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/anfischer/specification)[ Packagist](https://packagist.org/packages/anfischer/specification)[ Docs](https://github.com/anfischer/specification)[ RSS](/packages/anfischer-specification/feed)WikiDiscussions master Synced 2mo ago

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

PHP Specification pattern
=========================

[](#php-specification-pattern)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2e00142b16961fb700d972ec9a61ad165a77fe04ba11c53baebba6db9cb6abcd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e666973636865722f73706563696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/anfischer/specification)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/6b8ec2675d9b2fc5dc0a809e016b98896d91a1ec2f67a290a27e118985dc5edb/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616e666973636865722f73706563696669636174696f6e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/anfischer/specification)[![Coverage Status](https://camo.githubusercontent.com/a26d14bda6e59921057456b02693b73c348a7616998669c860cf308840f1e282/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f616e666973636865722f73706563696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/anfischer/specification/code-structure)[![Quality Score](https://camo.githubusercontent.com/cb9148afd6f640a90c614e35715fe1c6a6f72e554580f48761343b0173f02682/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616e666973636865722f73706563696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/anfischer/specification)[![Total Downloads](https://camo.githubusercontent.com/108da5518dddeed6ff60ccbd6035e0f6ee81963a1811ccc72b365e1815c50432/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e666973636865722f73706563696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/anfischer/specification)

A package containing base classes to be used as a starting ground for implementation of the Specification pattern in PHP (for more information see ).

This package includes the typical set of and(), or() and not() specifications as well as specifications for allOf(), anyOf() and noneOf().

Install
-------

[](#install)

Via Composer

```
$ composer require anfischer/specification
```

Usage
-----

[](#usage)

General usage of this package can be inferred from its test cases.
However a very basic and simplified example of usage with a single specification to (not) satisfy might look like this:

```
use Anfischer\Specification\Specification;

class Invoice
{
    public function isOverdue()
    {
        /* Logic snip */
        return true;
    }
}

class OverdueInvoiceSpecification extends Specification
{
    public function isSatisfiedBy($invoice): bool
    {
        return $invoice->isOverdue();
    }
}

$overdue = new OverdueInvoiceSpecification;

// Will return true
$overdue->isSatisfiedBy(new Invoice);

// Will return false
$overdue->not()->isSatisfiedBy(new Invoice);
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Andreas Fischer](https://github.com/anfischer)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

2880d ago

### Community

Maintainers

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

---

Top Contributors

[![anfischer](https://avatars.githubusercontent.com/u/2504884?v=4)](https://github.com/anfischer "anfischer (2 commits)")

---

Tags

specificationanfischer

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/anfischer-specification/health.svg)

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

###  Alternatives

[rikbruil/specification

A PHP implementation of the Specification-pattern

18284.8k1](/packages/rikbruil-specification)[maximecolin/satisfaction

A PHP implementation of the specification pattern for DDD

3630.2k](/packages/maximecolin-satisfaction)[kphoen/rulerz-spec-builder

Specification builder for RulerZ

1149.5k](/packages/kphoen-rulerz-spec-builder)[chalcedonyt/laravel-specification

Implementation of the specification pattern

128.6k](/packages/chalcedonyt-laravel-specification)[casinelli/currency

Handles currency for Laravel 5.

1911.8k](/packages/casinelli-currency)

PHPackages © 2026

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