$inputs the list of inputs in which the value at {@see $key} should be checked * @param string $key the key in {@see $inputs} of the input to check * @return void if the checked input equals the CLI password * @throws InvalidTypeException if the CLI password is a blank string, if the CLI password is at its default * value, or if the checked input is not set * @throws InvalidValueException if the checked input does not equal the CLI password */ public function check(array $inputs, string $key): void { if (!Config::has(self::CONFIG_KEY) || trim(Config::get(self::CONFIG_KEY)) === "") throw new IllegalStateError("The CLI is disabled because the CLI password is not set."); if (Config::get(self::CONFIG_KEY) === self::DEFAULT) throw new IllegalStateError("The CLI is disabled because the CLI password is set to the default."); if (!isset($inputs[$key])) throw new InvalidTypeException("This operation requires the CLI password."); if (!password_verify($inputs[$key], Config::get(self::CONFIG_KEY))) throw new InvalidValueException("Incorrect CLI password.", $key); } }