https://github.com/sebastianbergmann/comparator
Provides the functionality to compare PHP values for equality.
https://github.com/sebastianbergmann/comparator
Last synced: 2 months ago
JSON representation
Provides the functionality to compare PHP values for equality.
- Host: GitHub
- URL: https://github.com/sebastianbergmann/comparator
- Owner: sebastianbergmann
- License: bsd-3-clause
- Created: 2013-11-05T00:36:12.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2025-04-13T07:25:45.000Z (3 months ago)
- Last Synced: 2025-04-27T23:56:28.504Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 54.1 MB
- Stars: 7,034
- Watchers: 8
- Forks: 69
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
- php-awesome - Comparator - 对比两个 PHP 变量值是否相等 (类库 / 未归类)
README
[](https://packagist.org/packages/sebastian/comparator)
[](https://github.com/sebastianbergmann/comparator/actions)
[](https://codecov.io/gh/sebastianbergmann/comparator)# sebastian/comparator
This component provides the functionality to compare PHP values for equality.
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
```
composer require sebastian/comparator
```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 sebastian/comparator
```## Usage
```php
getComparatorFor($date1, $date2);try {
$comparator->assertEquals($date1, $date2);
print "Dates match";
} catch (ComparisonFailure $failure) {
print "Dates don't match";
}
```