| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class MapBasedSorter extends AbstractPropertyBasedSorter implements CollectionSorterInterface |
||
| 10 | { |
||
| 11 | protected array $map = []; |
||
| 12 | |||
| 13 | 9 | public function setMap(array $map): MapBasedSorter |
|
| 14 | { |
||
| 15 | 9 | $this->map = $map; |
|
| 16 | |||
| 17 | 9 | return $this; |
|
| 18 | } |
||
| 19 | |||
| 20 | 9 | public function setProperty(string $property): MapBasedSorter |
|
| 23 | } |
||
| 24 | |||
| 25 | 6 | protected function getSortingFunction(string $order = OrderInterface::ASC): callable |
|
| 26 | { |
||
| 27 | 6 | return fn ($a, $b): int => $this->resolveEntriesOrder( |
|
| 28 | 6 | $this->getComparisonValueFor($a), |
|
| 29 | 6 | $this->getComparisonValueFor($b), |
|
| 30 | $order |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | 6 | protected function getComparisonValueFor($item): int |
|
| 37 | } |
||
| 38 | } |
||
| 39 |