mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-27 02:00:20 +02:00
21 lines
390 B
PHP
21 lines
390 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Behavioral\Strategy;
|
|
|
|
class DateComparator implements Comparator
|
|
{
|
|
/**
|
|
* @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;
|
|
}
|
|
}
|