26 private array $intToStringIdMap = [];
31 private array $stringToIntMap = [];
38 foreach($this->itemTypes as $type){
39 $this->stringToIntMap[$type->getStringId()] = $type->getNumericId();
40 $this->intToStringIdMap[$type->getNumericId()] = $type->getStringId();
49 return $this->itemTypes;
52 public function fromStringId(
string $stringId) : int{
53 if(!array_key_exists($stringId, $this->stringToIntMap)){
54 throw new \InvalidArgumentException(
"Unmapped string ID \"$stringId\"");
56 return $this->stringToIntMap[$stringId];
59 public function fromIntId(
int $intId) : string{
60 if(!array_key_exists($intId, $this->intToStringIdMap)){
61 throw new \InvalidArgumentException(
"Unmapped int ID $intId");
63 return $this->intToStringIdMap[$intId];