$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 InvalidInputException if the checked input does not equal the CLI password * @throws IllegalArgumentError if the CLI password is a blank string, if the CLI password is at its default value, * if the checked input is not set */ public function check(array $inputs, string $key): void { if (!Config::has(self::CONFIG_KEY) || trim(Config::get(self::CONFIG_KEY)) === "") throw new IllegalArgumentError("The CLI is disabled because the CLI password is not set."); if (Config::get(self::CONFIG_KEY) === self::DEFAULT) throw new IllegalArgumentError("The CLI is disabled because the CLI password is set to the default."); if (!isset($inputs[$key])) throw new InvalidInputException("This operation requires the CLI password.", $key); if (!password_verify($inputs[$key], Config::get(self::CONFIG_KEY))) throw new InvalidInputException("Incorrect CLI password.", $key); } }