1 | <?php |
||
18 | class ComplexSortStrategy extends AbstractSortStrategy implements StrategyInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | private $propertyMap = array(); |
||
24 | |||
25 | /** |
||
26 | * @param ComparatorInterface $comparator |
||
27 | */ |
||
28 | 3 | function __construct(ComparatorInterface $comparator = null) |
|
35 | |||
36 | /** |
||
37 | * @param mixed $accessor Closure or object property name that returns value supported by comparator |
||
38 | * @param int $order Sort sortOrder |
||
39 | * @param ComparatorInterface $comparator Exclusive comparator for given property |
||
40 | * |
||
41 | * @return $this |
||
42 | */ |
||
43 | 1 | public function sortBy($accessor, $order = null, ComparatorInterface $comparator = null) |
|
53 | |||
54 | /** |
||
55 | * Create a callback used in usort |
||
56 | * |
||
57 | * @return \Closure |
||
58 | */ |
||
59 | 1 | protected function createSortTransformFunction() |
|
87 | |||
88 | /** |
||
89 | * Get callable used for extracting values from sortable entities (objects, arrays etc.) |
||
90 | * This method extracts value from k, where k is an element of collection(i => k). |
||
91 | * Accessor can be customized to add sorting ability to a complex objects. |
||
92 | * |
||
93 | * @return \Closure Takes two arguments, $property and $accessor |
||
94 | */ |
||
95 | private function getPropertyExtractor() |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | 1 | public function sort(array $collection) |
|
129 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.