mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-19 21:18:39 +00:00
fixes
This commit is contained in:
parent
1e19f72fc4
commit
6ac2d4d0e8
|
|
@ -35,6 +35,21 @@ final class Continuous
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparing items
|
||||
*
|
||||
* @param Item[] $a Item
|
||||
* @param Item[] $b Item
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function continuousComparator(array $a, array $b) : int
|
||||
{
|
||||
return $b['item']->getValue() / $b['item']->getCost() <=> $a['item']->getValue() / $a['item']->getCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the backpack with items
|
||||
*
|
||||
|
|
@ -47,9 +62,7 @@ final class Continuous
|
|||
*/
|
||||
public static function solve(array $items, BackpackInterface $backpack) : BackpackInterface
|
||||
{
|
||||
\usort($items, function($a, $b) {
|
||||
return $a['item']->getValue() / $a['item']->getCost() < $b['item']->getValue() / $b['item']->getCost();
|
||||
});
|
||||
\usort($items, ['self', 'continuousComparator']);
|
||||
|
||||
$availableSpace = $backpack->getMaxCost();
|
||||
|
||||
|
|
|
|||
|
|
@ -363,11 +363,13 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
public static function clear() : void
|
||||
{
|
||||
// clear parent and objects
|
||||
if (static::class === self::$parentMapper) {
|
||||
self::$parentMapper = null;
|
||||
self::$conditionals = [];
|
||||
self::$relations = RelationType::ALL;
|
||||
if (static::class !== self::$parentMapper) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$parentMapper = null;
|
||||
self::$conditionals = [];
|
||||
self::$relations = RelationType::ALL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user