PHP7 Strategy

This commit is contained in:
Dominik Liebler
2016-09-22 11:02:03 +02:00
parent 9b9eee5a4c
commit 36f3df8fbb
5 changed files with 47 additions and 53 deletions

View File

@@ -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'];
}
}