PHPackages                             danielkellyio/value-comparison - 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. danielkellyio/value-comparison

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

danielkellyio/value-comparison
==============================

Compare a value to another value in order to perform advanced logic on user input (comparisons such as greater than, starts with, contains and with any or all to compare against multiple)

1.0.0(6y ago)13.1k↓69.6%MITPHPPHP &gt;=7.1CI failing

Since Oct 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/danielkellyio/value-comparison)[ Packagist](https://packagist.org/packages/danielkellyio/value-comparison)[ RSS](/packages/danielkellyio-value-comparison/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Value Comparison
================

[](#value-comparison)

Compare value to another value in order to perform advanced logic on user input (comparisons such as greater than, starts with, contains and with any or all to compare against multiple)

Why Value Comparison Library?
=============================

[](#why-value-comparison-library)

Value comparison is simple, why have a library for it? My use case is to take an operator from user input (an html select field), so:

1. Having the operators in word format solved 2 issues:
    - can't have dynamic operators
    - provides non-coder friendly terminology
2. Having the ability to pass "any" or "all" (once again from user input comma separated seemed a no-brainer)
3. Full test coverage for confidence that it'll works every time
4. This makes ValueComparison perfectly fit to handle the input of a user interface like this: [![screenshot](screenshot.png)](screenshot.png)

Installation
============

[](#installation)

```
composer require danielkellyio/value-comparison

```

Examples
========

[](#examples)

```
use DanielKellyIO\ValueComparison\Compare;

// Check if string contains another string
Compare::value('Value to test')->contains('test'); // true

//Check if string contains ANY other strings (pass an array or string with values comma seperated)
Compare::value('Value to test')->contains('test, not, there', 'any'); // true
//or
Compare::value('Value to test')->contains(['test', 'not', 'there'], 'any'); // true

//Check if string contains ALL other strings (pass an array or string with values comma seperated)
Compare::value('Value to test')->contains('test, not, there', 'all'); // false
//or
Compare::value('Value to test')->contains(['test', 'not', 'there'], 'all'); // false

```

Methods
=======

[](#methods)

- **is** - check if value is exact match to comparison value (coerced to string)
- **isNot** - check if value is NOT an exact match to comparison value (coerced to string)
- **greaterThan** - check if value is greater than comparison value (coerced to integer)
- **lessThan** - check if value is less than comparison value (coerced to integer)
- **contains** - check if value is contains comparison value (coerced to string)
- **excludes** - check if value is excludes comparison value (coerced to string)
- **startsWith** - check if value is starts with comparison value (coerced to string)
- **endsWith** - check if value is ends with comparison value (coerced to string)

Scopes
======

[](#scopes)

- **null** - treats comparison value as a single entity to compare against value
- **any** - value only has to match one of the comparison values (comparison value can be array or comma seperated string)
- **all** - value has to match ALL of the comparison values (comparison value can be array or comma seperated string)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

2454d ago

### Community

Maintainers

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

---

Tags

logiccompare valueslogic on values

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/danielkellyio-value-comparison/health.svg)

```
[![Health](https://phpackages.com/badges/danielkellyio-value-comparison/health.svg)](https://phpackages.com/packages/danielkellyio-value-comparison)
```

###  Alternatives

[unclecheese/display-logic

Allows assignment of conditions for display and hide of specific form fields based on client side behavior.

771.1M114](/packages/unclecheese-display-logic)

PHPackages © 2026

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