mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 17:52:25 +01:00
22 lines
346 B
PHP
22 lines
346 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Strategy;
|
|
|
|
/**
|
|
* Class IdComparator
|
|
*/
|
|
class IdComparator implements ComparatorInterface
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function compare($a, $b)
|
|
{
|
|
if ($a['id'] == $b['id']) {
|
|
return 0;
|
|
} else {
|
|
return $a['id'] < $b['id'] ? -1 : 1;
|
|
}
|
|
}
|
|
}
|