sebastian / comparator
提供比较 PHP 值是否相等的功能
6.1.0
2024-09-11 15:42 UTC
Requires
- php: >=8.2
- ext-dom: *
- ext-mbstring: *
- sebastian/diff: ^6.0
- sebastian/exporter: ^6.0
Requires (Dev)
- phpunit/phpunit: ^11.3
This package is auto-updated.
Last update: 2024-09-11 15:44:19 UTC
README
sebastian/comparator
此组件提供了比较 PHP 值是否相等的功能。
安装
您可以使用 Composer 将此库作为本地、按项目依赖项添加到项目中
composer require sebastian/comparator
如果您只需要在开发期间使用此库,例如运行项目的测试套件,那么您应该将其添加为开发时依赖项
composer require --dev sebastian/comparator
用法
<?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"; }