| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | protected function fillPartitions(Partitions $partitions, Partition $dataset, int $chunks): void |
||
| 21 | { |
||
| 22 | $partitionItemFactory = $this->getPartitionItemFactory(); |
||
| 23 | |||
| 24 | // Greedy needs a dataset sorted DESC. |
||
| 25 | $dataset->uasort(static function ($a, $b) use ($partitionItemFactory) { |
||
| 26 | $left = $partitionItemFactory::create($a); |
||
| 27 | $right = $partitionItemFactory::create($b); |
||
| 28 | |||
| 29 | return $right->getWeight() <=> $left->getWeight(); |
||
| 30 | }); |
||
| 31 | |||
| 32 | foreach ($dataset as $data) { |
||
| 33 | $partitions |
||
| 34 | ->sort() |
||
| 35 | ->partition(0) |
||
| 36 | ->append($data); |
||
| 37 | } |
||
| 40 |