diff --git a/src/muqsit/tebex/handler/command/RegisteredTebexCommandExecutor.php b/src/muqsit/tebex/handler/command/RegisteredTebexCommandExecutor.php index 44a6e00..bbc12c2 100644 --- a/src/muqsit/tebex/handler/command/RegisteredTebexCommandExecutor.php +++ b/src/muqsit/tebex/handler/command/RegisteredTebexCommandExecutor.php @@ -132,9 +132,7 @@ public function registerSubCommand(TebexSubCommand $sub_command) : void{ } public function unregisterSubCommand(string $name) : void{ - if(!isset($this->sub_commands[$name])){ - throw new InvalidArgumentException("Tried unregistering an unregistered sub-command: {$name}"); - } + isset($this->sub_commands[$name]) || throw new InvalidArgumentException("Tried unregistering an unregistered sub-command: {$name}"); foreach($this->sub_commands[$name]->aliases as $alias){ unset($this->aliases[$alias]); } diff --git a/src/muqsit/tebex/handler/due/playerlist/indexer/XuidBasedPlayerIndexer.php b/src/muqsit/tebex/handler/due/playerlist/indexer/XuidBasedPlayerIndexer.php index 5821d6b..545b9dd 100644 --- a/src/muqsit/tebex/handler/due/playerlist/indexer/XuidBasedPlayerIndexer.php +++ b/src/muqsit/tebex/handler/due/playerlist/indexer/XuidBasedPlayerIndexer.php @@ -15,9 +15,7 @@ public function __construct(){ public function fromPlayer(Player $player) : string{ $xuid = $player->getXuid(); - if($xuid === ""){ - throw new InvalidArgumentException("Cannot retrieve XUID of player: {$player->getName()}"); - } + $xuid !== "" || throw new InvalidArgumentException("Cannot retrieve XUID of player: {$player->getName()}"); return $xuid; } diff --git a/src/muqsit/tebex/thread/TebexThreadPool.php b/src/muqsit/tebex/thread/TebexThreadPool.php index cced60c..b2ce2fc 100644 --- a/src/muqsit/tebex/thread/TebexThreadPool.php +++ b/src/muqsit/tebex/thread/TebexThreadPool.php @@ -8,6 +8,7 @@ use pocketmine\Server; use pocketmine\snooze\SleeperHandlerEntry; use UnderflowException; +use function count; final class TebexThreadPool{ @@ -36,10 +37,7 @@ public function addWorker(TebexThread $thread) : void{ } public function start() : void{ - if(count($this->workers) === 0){ - throw new UnderflowException("Cannot start an empty pool of workers"); - } - + count($this->workers) > 0 || throw new UnderflowException("Cannot start an empty pool of workers"); foreach($this->workers as $thread){ $thread->start(); } diff --git a/src/muqsit/tebex/utils/TypeValidator.php b/src/muqsit/tebex/utils/TypeValidator.php index 1694c7d..ed8128e 100644 --- a/src/muqsit/tebex/utils/TypeValidator.php +++ b/src/muqsit/tebex/utils/TypeValidator.php @@ -5,6 +5,9 @@ namespace muqsit\tebex\utils; use InvalidArgumentException; +use function is_array; +use function is_int; +use function is_string; final class TypeValidator{ @@ -13,9 +16,7 @@ private static function printValue(mixed $value) : string{ } public static function validateInt(string $key, mixed $value, int $min = PHP_INT_MIN, int $max = PHP_INT_MAX) : int{ - if(!is_int($value)){ - throw new InvalidArgumentException("Invalid value for {$key}: " . self::printValue($value)); - } + is_int($value) || throw new InvalidArgumentException("Invalid value for {$key}: " . self::printValue($value)); if($value < $min || $value > $max){ throw new InvalidArgumentException("{$key}'s value is out of range [{$min}, {$max}]"); } @@ -23,9 +24,7 @@ public static function validateInt(string $key, mixed $value, int $min = PHP_INT } public static function validateString(string $key, mixed $value) : string{ - if(!is_string($value)){ - throw new InvalidArgumentException("Invalid value for {$key}: " . self::printValue($value)); - } + is_string($value) || throw new InvalidArgumentException("Invalid value for {$key}: " . self::printValue($value)); return $value; } @@ -35,9 +34,7 @@ public static function validateString(string $key, mixed $value) : string{ * @return string[] */ public static function validateStringList(string $key, mixed $value) : array{ - if(!is_array($value)){ - throw new InvalidArgumentException("Invalid value for {$key}: " . self::printValue($value)); - } + is_array($value) || throw new InvalidArgumentException("Invalid value for {$key}: " . self::printValue($value)); foreach($value as $index => $item){ self::validateString("{$key}.{$index}", $item); }