PriceComparator.php in Commerce Core 8.2
File
modules/price/src/Comparator/PriceComparator.php
View source
<?php
namespace Drupal\commerce_price\Comparator;
use Drupal\commerce_price\Price;
use SebastianBergmann\Comparator\Comparator;
use SebastianBergmann\Comparator\ComparisonFailure;
class PriceComparator extends Comparator {
public function accepts($expected, $actual) {
return $expected instanceof Price && $actual instanceof Price;
}
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = FALSE, $ignoreCase = FALSE) {
assert($expected instanceof Price);
assert($actual instanceof Price);
if (!$actual
->equals($expected)) {
throw new ComparisonFailure($expected, $actual, (string) $expected, (string) $actual, FALSE, sprintf('Failed asserting that Price %s matches expected %s.', $actual, $expected));
}
}
}