/
example_object_storage.php
36 lines (28 loc) · 1.04 KB
/
example_object_storage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require_once(__DIR__ . '/../vendor/autoload.php');
use \JanMaennig\Sorty\Tests\Fixtures\ObjectStorageValueSorterCollectionFixture;
use \JanMaennig\Sorty\Tests\Fixtures\ObjectStorageValueSorterRecordFixture;
$exampleCollection = new ObjectStorageValueSorterCollectionFixture();
$exampleCollection->offsetSet(
0,
new ObjectStorageValueSorterRecordFixture('Müller', 'Dresden', '04059 09409508')
);
$exampleCollection->offsetSet(
1,
new ObjectStorageValueSorterRecordFixture('Müller', 'Leipzig', '04059 09409508')
);
$exampleCollection->offsetSet(
2,
new ObjectStorageValueSorterRecordFixture('Maier', 'Stuttgart', '04059 09409508')
);
$exampleCollection->offsetSet(
3,
new ObjectStorageValueSorterRecordFixture('Schmidt', 'Hamburg', '04059 09409508')
);
$sortedPropertiesDirections = [
'name' => SORT_ASC,
'city' => SORT_DESC
];
$objectStorageSorter = new \JanMaennig\Sorty\ObjectStorageValueSorter();
$result = $objectStorageSorter->sorting($exampleCollection, $sortedPropertiesDirections);
print_r($result);