PHPackages                             kayladnls/spec - 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. kayladnls/spec

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

kayladnls/spec
==============

Specification in PHP

v0.1.2(10y ago)12172MITPHPPHP &gt;=5.5

Since Jul 23Pushed 10y agoCompare

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

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

\#Spec A Simple Specification library for PHP

[![Build Status](https://camo.githubusercontent.com/82ce695f15e07a506c307b981f497c3d20958544428fe295ae1d6c0640125209/68747470733a2f2f7472617669732d63692e6f72672f6b61796c61646e6c732f737065632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kayladnls/spec) [![Code Climate](https://camo.githubusercontent.com/0a427af82b1e6e54f45357c1fb97a80b9edeec74acb725843a8ec8584caaae37/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6b61796c61646e6c732f737065632f6261646765732f6770612e737667)](https://codeclimate.com/github/kayladnls/spec)

### Installation

[](#installation)

```
composer require kayladnls/spec

```

### What is it?

[](#what-is-it)

> "the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic. The pattern is frequently used in the context of domain-driven design." -- [wikipedia](https://en.wikipedia.org/wiki/Specification_pattern)

### How do I use it?

[](#how-do-i-use-it)

#### Use the builder

[](#use-the-builder)

```
$all_spec = Kayladnls/Spec/Builder::all(new MustHaveFourLegs(), new MustHaveStripesSpec());

$all_spec->isSatisfiedBy($elephpant) //False
$all_spec->isSatisfiedBy($zebra)     // True

$any_spec = Kayladnls/Spec/Builder::any($all_spec, new IsLizardSpec());
$any_spec->isSatisfiedBy($iguana) // True
```

Or, you can use functions if that's what tickles your fancy.

#### Function Based

[](#function-based)

```
$all_spec = Kayladnls/Spec/all([new MustHaveFourLegs(), new MustHaveStripesSpec()]);

Kayladnls/Spec/satisfies($elephpant, $all_spec) //False
Kayladnls/Spec/satisfies($zebra, $all_spec) //True

$any_spec = Kayladnls/Spec/any([$all_spec, new IsLizardSpec()]);
Kayladnls/Spec/satisfies($iguana, $any_spec) // True

$none_spec = Kayladnls/Spec/none([new MustHaveFourLegs(), new MustHaveSpotsSpec()]);
Kayladnls/Spec/satisfies($kangaroo, $none_spec) // true
Kayladnls/Spec/satisfies($cheetah, $none_spec) // false
```

### Example

[](#example)

```
if ($all_spec->isSatisfiedBy($zebra)){
	// Do Some cool Zebra Stuff here.
}

// Function Based
if (satisfies($iguana, $any_spec)){
	// do some cool lizard-based stuff here.
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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 ~13 days

Total

3

Last Release

3927d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12d34e4d0259dc2a2460d2803beeffb06e778064b93cac1b8f289f2d7e13b23f?d=identicon)[greydnls](/maintainers/greydnls)

---

Top Contributors

[![greydnls](https://avatars.githubusercontent.com/u/1276798?v=4)](https://github.com/greydnls "greydnls (27 commits)")[![jeroenvdgulik](https://avatars.githubusercontent.com/u/242090?v=4)](https://github.com/jeroenvdgulik "jeroenvdgulik (2 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (1 commits)")

### Embed Badge

![Health badge](/badges/kayladnls-spec/health.svg)

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

###  Alternatives

[aginev/datagrid

Datagrid Package for Laravel v5+

4828.7k](/packages/aginev-datagrid)[cslant/laravel-like

A package providing 👍 like, 👎 dislike and love ❤️ or unlike ✋features features for Laravel applications.

2422.2k1](/packages/cslant-laravel-like)[xeeeveee/sudoku

PHP sudoku logic library - Generate and solve sudoku puzzles

2814.1k](/packages/xeeeveee-sudoku)[bicpi/html-converter

HTML-to-Text converter library

1120.7k1](/packages/bicpi-html-converter)[sun/country

Sun Country is the package that helps you to get the country name &amp; dialing code by the country ISO 3166-1 Alpha-2 code.

1016.5k](/packages/sun-country)

PHPackages © 2026

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