*/ private array $reverseSlotMap = []; /** * @param int[] $slotMap * @phpstan-param array $slotMap */ public function __construct( private Inventory $inventory, private array $slotMap ){ foreach($slotMap as $slot => $index){ $this->reverseSlotMap[$index] = $slot; } } public function getInventory() : Inventory{ return $this->inventory; } /** * @return int[] * @phpstan-return array */ public function getSlotMap() : array{ return $this->slotMap; } public function mapNetToCore(int $slot) : ?int{ return $this->slotMap[$slot] ?? null; } public function mapCoreToNet(int $slot) : ?int{ return $this->reverseSlotMap[$slot] ?? null; } }