mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 04:00:18 +02:00
PHP7 Strategy
This commit is contained in:
@@ -5,14 +5,13 @@ namespace DesignPatterns\Behavioral\Strategy;
|
||||
class IdComparator implements ComparatorInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param mixed $a
|
||||
* @param mixed $b
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function compare($a, $b)
|
||||
public function compare($a, $b): int
|
||||
{
|
||||
if ($a['id'] == $b['id']) {
|
||||
return 0;
|
||||
} else {
|
||||
return $a['id'] < $b['id'] ? -1 : 1;
|
||||
}
|
||||
return $a['id'] <=> $b['id'];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user