phpzendo / php-comparison
The most awesome comparison engine created for php
v1.0.1
2018-06-08 02:28 UTC
Requires
- php: >=7.1
- florianwolters/component-core-comparable: 0.2.*
- sebastian/comparator: ^3.0
Requires (Dev)
- phpunit/phpunit: ^7.2@dev
- symfony/var-dumper: 3.4.x-dev
This package is not auto-updated.
Last update: 2025-04-08 20:51:39 UTC
README
About PHP-COMPARISON
The most awesome comparison engine created for php.
Features
- Provide uniform empty method.
- Provide uniform isset method.
- Provide uniform is null method.
- Provide the functionality to compare PHP values for great than, less than, great than or equal and less than or equal check.
- Much more.
Requires
- PHP version 7.1+.
- sebastian/comparator component.
- florianwolters/component-core-comparable component.
Installation
You can add this library as a local, per-project dependency to your project using Composer:
composer require phpzendo/php-comparison
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev phpzendo/php-comparison
Usage
Verify the given value is empty.
<?php use PhpZendo\Comparison\Compare; $comparator = Compare::getInstance(); $comparator->empty(null);
Verify the given value is null.
<?php use PhpZendo\Comparison\Compare; $comparator = Compare::getInstance(); $comparator->isNull(null);
Verify the given value is set.
<?php use PhpZendo\Comparison\Compare; $comparator = Compare::getInstance(); $comparator->isset(null);
Compare two values.
<?php use PhpZendo\Comparison\Compare; $comparator = Compare::getInstance(); $comparator->gt($expected = 2, $actual = 1);// Check $expected great than $actual. $comparator->gte($expected = 1, $actual = 1);// Check $expected great than or equal $actual. $comparator->lt($expected = 1, $actual = 2);// Check $expected less than $actual. $comparator->lte($expected = 2, $actual = 2);// Check $expected less than or equal $actual.
Change Log
2018-06-04 17:05
Established!
2018-06-09 22:36
Add compare helper functions.