Files
DesignPatternsPHP/Behavioral/Strategy/DateComparator.php
Antonio Spinelli e59d70a0ac start a restructure
2014-03-21 18:03:45 -03:00

25 lines
423 B
PHP

<?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;
}
}
}