Make GameMode::fromString() and PluginEnableOrder::fromString() return null, instead of throwing exceptions

since these are always used for handling userdata, it doesn't make sense for them to throw exceptions.
This commit is contained in:
Dylan K. Taylor
2021-06-27 20:56:51 +01:00
parent 3dd33cd35e
commit 6fb8ac211e
5 changed files with 11 additions and 21 deletions

View File

@ -61,13 +61,9 @@ final class GameMode{
}
}
public static function fromString(string $str) : self{
public static function fromString(string $str) : ?self{
self::checkInit();
$result = self::$aliasMap[mb_strtolower($str)] ?? null;
if($result === null){
throw new \InvalidArgumentException("Invalid gamemode alias $str");
}
return $result;
return self::$aliasMap[mb_strtolower($str)] ?? null;
}
/** @var int */