mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 04:00:18 +02:00
start a restructure
This commit is contained in:
21
Behavioral/Strategy/IdComparator.php
Normal file
21
Behavioral/Strategy/IdComparator.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user