Mercurial > hg > isophonics-drupal-site
annotate vendor/sebastian/comparator/README.md @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 1fec387a4317 |
children |
rev | line source |
---|---|
Chris@0 | 1 [](https://travis-ci.org/sebastianbergmann/comparator) |
Chris@0 | 2 |
Chris@0 | 3 # Comparator |
Chris@0 | 4 |
Chris@0 | 5 This component provides the functionality to compare PHP values for equality. |
Chris@0 | 6 |
Chris@0 | 7 ## Installation |
Chris@0 | 8 |
Chris@0 | 9 You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/): |
Chris@0 | 10 |
Chris@0 | 11 composer require sebastian/comparator |
Chris@0 | 12 |
Chris@0 | 13 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: |
Chris@0 | 14 |
Chris@0 | 15 composer require --dev sebastian/comparator |
Chris@0 | 16 |
Chris@0 | 17 ## Usage |
Chris@0 | 18 |
Chris@0 | 19 ```php |
Chris@0 | 20 <?php |
Chris@0 | 21 use SebastianBergmann\Comparator\Factory; |
Chris@0 | 22 use SebastianBergmann\Comparator\ComparisonFailure; |
Chris@0 | 23 |
Chris@0 | 24 $date1 = new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')); |
Chris@0 | 25 $date2 = new DateTime('2013-03-29 03:13:35', new DateTimeZone('America/Chicago')); |
Chris@0 | 26 |
Chris@0 | 27 $factory = new Factory; |
Chris@0 | 28 $comparator = $factory->getComparatorFor($date1, $date2); |
Chris@0 | 29 |
Chris@0 | 30 try { |
Chris@0 | 31 $comparator->assertEquals($date1, $date2); |
Chris@0 | 32 print "Dates match"; |
Chris@14 | 33 } catch (ComparisonFailure $failure) { |
Chris@0 | 34 print "Dates don't match"; |
Chris@0 | 35 } |
Chris@0 | 36 ``` |
Chris@0 | 37 |