mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-13 18:34:06 +02:00
start a restructure
This commit is contained in:
24
Behavioral/Strategy/DateComparator.php
Normal file
24
Behavioral/Strategy/DateComparator.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Strategy;
|
||||
|
||||
/**
|
||||
* Class DateComparator
|
||||
*/
|
||||
class DateComparator implements ComparatorInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function compare($a, $b)
|
||||
{
|
||||
$aDate = strtotime($a['date']);
|
||||
$bDate = strtotime($b['date']);
|
||||
|
||||
if ($aDate == $bDate) {
|
||||
return 0;
|
||||
} else {
|
||||
return $aDate < $bDate ? -1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user