function AbstractCollection::getComparator
2 calls to AbstractCollection::getComparator()
- AbstractCollection::diff in vendor/
ramsey/ collection/ src/ AbstractCollection.php - AbstractCollection::intersect in vendor/
ramsey/ collection/ src/ AbstractCollection.php
File
-
vendor/
ramsey/ collection/ src/ AbstractCollection.php, line 360
Class
- AbstractCollection
- This class provides a basic implementation of `CollectionInterface`, to minimize the effort required to implement this interface
Namespace
Ramsey\CollectionCode
private function getComparator() : Closure {
return function (mixed $a, mixed $b) : int {
// If the two values are object, we convert them to unique scalars.
// If the collection contains mixed values (unlikely) where some are objects
// and some are not, we leave them as they are.
// The comparator should still work and the result of $a < $b should
// be consistent but unpredictable since not documented.
if (is_object($a) && is_object($b)) {
$a = spl_object_id($a);
$b = spl_object_id($b);
}
return $a === $b ? 0 : ($a < $b ? 1 : -1);
};
}