mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-13 11:26:22 +02:00
19 lines
316 B
PHP
19 lines
316 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Behavioral\Strategy;
|
|
|
|
use DateTime;
|
|
|
|
class DateComparator implements Comparator
|
|
{
|
|
public function compare($a, $b): int
|
|
{
|
|
$aDate = new DateTime($a['date']);
|
|
$bDate = new DateTime($b['date']);
|
|
|
|
return $aDate <=> $bDate;
|
|
}
|
|
}
|