PHPackages                             codeliner/php-equalsbuilder - 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. codeliner/php-equalsbuilder

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

codeliner/php-equalsbuilder
===========================

EqualsBuilder for PHP.

1.2.0(12y ago)64.5k[4 issues](https://github.com/codeliner/php-equalsbuilder/issues)2BSD-3-ClausePHP

Since Jan 10Pushed 12y ago1 watchersCompare

[ Source](https://github.com/codeliner/php-equalsbuilder)[ Packagist](https://packagist.org/packages/codeliner/php-equalsbuilder)[ Docs](https://github.com/codeliner/php-equalsbuilder)[ RSS](/packages/codeliner-php-equalsbuilder/feed)WikiDiscussions master Synced 4d ago

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

EqualsBuilder
=============

[](#equalsbuilder)

EqualsBuilder for PHP

[![Build Status](https://camo.githubusercontent.com/b7148d7ea519f53b75e093350eb57b98536168e77f5deb142a6b2e0509bb6c4c/68747470733a2f2f7472617669732d63692e6f72672f636f64656c696e65722f7068702d657175616c736275696c6465722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/codeliner/php-equalsbuilder)

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

[](#installation)

Installation of codeliner/php-equalsbuilder uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/). Add following requirement to your composer.json

```
"codeliner/php-equalsbuilder" : "1.2.*"
```

Usage
-----

[](#usage)

Use the EqualsBuilder to compare any number of value pairs at once.

```
echo EqualsBuilder::create()
                ->append('equals', 'equals')
                ->append(1, 1)
                ->append(1, '1')
                ->equals() ?
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: All value pairs are equal
```

You can enable strict mode to compare against the value types, too.

```
echo EqualsBuilder::create()
                ->append('equals', 'equals')
                ->append(1, 1)
                ->append(1, '1')
                ->strict() //enable strict mode
                ->equals() ?
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: At least one value pair is not equal
```

If you only provide the first parameter the second one is set to true. This enables you to use comparison methods of objects together with the EqualsBuilder.

```
echo EqualsBuilder::create()
                ->append($vo->sameValueAs($otherVo))
                ->append(1, 1)
                ->append(1, '1')
                ->equals() ?
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: All value pairs are equal
```

You can also provide a callback as third parameter which is called with the value pair. The callback should return a boolean value.

```
echo EqualsBuilder::create()
                ->append($vo, $otherVo, function($a, $b) { return $a->sameValueAs($b);})
                ->append(1, 1)
                ->append(1, '1')
                ->equals() ?
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: All value pairs are equal
```

The callback option gets really interesting when $a and $b are array lists (arrays with continuous integer keys starting at 0 and ending at count - 1 ). In this case the callback is called for every item in list $a together with the corresponding item of list $b assumed that count($a) == count($b) is true.

```
$aList = array($vo1, $vo2, $vo3);
$bList = array($vo1, $vo2, $vo3);

echo EqualsBuilder::create()
                ->append($aList, $bList, function($aVO, $bVO) { return $aVO->sameValueAs($bVO);})
                ->append(1, 1)
                ->append(1, '1')
                ->equals() ?
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: All value pairs are equal
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Total

4

Last Release

4403d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5131987?v=4)[Alexander Miertsch](/maintainers/codeliner)[@codeliner](https://github.com/codeliner)

---

Tags

equalsEqualsBuilder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codeliner-php-equalsbuilder/health.svg)

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

PHPackages © 2026

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