merged from master

This commit is contained in:
Antonio Spinelli
2014-04-15 22:07:48 -03:00
14 changed files with 241 additions and 31 deletions

View File

@@ -12,8 +12,8 @@ class DateComparator implements ComparatorInterface
*/
public function compare($a, $b)
{
$aDate = strtotime($a['date']);
$bDate = strtotime($b['date']);
$aDate = new \DateTime($a['date']);
$bDate = new \DateTime($b['date']);
if ($aDate == $bDate) {
return 0;

View File

@@ -1,21 +0,0 @@
<?php
namespace DesignPatterns\Strategy;
$elements = array(
array(
'id' => 2,
'date' => '2011-01-01',
),
array(
'id' => 1,
'date' => '2011-02-01'
)
);
$collection = new ObjectCollection($elements);
$collection->setComparator(new IdComparator());
$collection->sort();
$collection->setComparator(new DateComparator());
$collection->sort();