mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 17:52:25 +01:00
21 lines
374 B
PHP
21 lines
374 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\Strategy;
|
|
|
|
class DateComparator implements ComparatorInterface
|
|
{
|
|
/**
|
|
* @param mixed $a
|
|
* @param mixed $b
|
|
*
|
|
* @return int
|
|
*/
|
|
public function compare($a, $b): int
|
|
{
|
|
$aDate = new \DateTime($a['date']);
|
|
$bDate = new \DateTime($b['date']);
|
|
|
|
return $aDate <=> $bDate;
|
|
}
|
|
}
|