DesignPatternsPHP/Strategy/DateComparator.php
Dominik Liebler 3808eab0a0 cs Strategy
2013-09-12 11:37:03 +02: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;
}
}
}