sebastian/comparator
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
sebastian/diff | 5.0.3 | 23.94 kB | BSD-3-Clause | prod | |
sebastian/exporter | 5.1.1 | 8.15 kB | BSD-3-Clause | prod |
Sebastian/comparator is a handy PHP library that provides the functionality to compare PHP values for equality. This could be beneficial in numerous scenarios where you need to ascertain if the given PHP values are equal or not.
To use sebastian/comparator, you need to follow these simple steps:
First, you need to install the library using Composer. It can be added either as a local, per-project dependency:
composer require sebastian/comparator
Or, if you only need this library during development (for instance, to run your project's test suite), you can add it as a development-time dependency:
composer require --dev sebastian/comparator
Once installed, you can use it in your PHP scripts like so:
<?php
use SebastianBergmann\Comparator\Factory;
use SebastianBergmann\Comparator\ComparisonFailure;
$date1 = new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York'));
$date2 = new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/Chicago'));
$factory = new Factory;
$comparator = $factory->getComparatorFor($date1, $date2);
try {
$comparator->assertEquals($date1, $date2);
print "Dates match";
} catch (ComparisonFailure $failure) {
print "Dates don't match";
}
In the above snippet, we're using the library to compare two date objects.
The Sebastian/comparator's documentation isn't hosted on a separate website. You can instead refer to its GitHub page for detailed instructions on installing and using the library. The "readme" file in the repository provides a comprehensive guide to get started with sebastian/comparator.