Skip to content

Commit

Permalink
[TASK] Split error handling for settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rtp-cgs committed Dec 4, 2023
1 parent a46ea00 commit bb3d1e1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/RequestMethod/CurlPostWithProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public function injectSettings(array $settings)
throw new \Exception("Missing configuration, please add the following settings: 'Wegmeister.Recaptcha.httpProxy'");
}

if(!is_string($settings['httpProxy'])){
throw new \Exception("Invalid configuration, the Wegmeister.Recaptcha.httpProxy option has to be a string.");
}

$httpProxyParts = explode(':', $settings['httpProxy']);
// check if the settings is a string & has exactly two parts & the port only contains numbers
if(!is_string($settings['httpProxy']) || count($httpProxyParts) !== 2 || (int)$httpProxyParts[1] === 0){
if(count($httpProxyParts) !== 2 || (int)$httpProxyParts[1] === 0){
throw new \Exception("Invalid configuration, the Wegmeister.Recaptcha.httpProxy option should have the following format: 'http://yourproxy.com:1234'");
}

Expand Down

0 comments on commit bb3d1e1

Please sign in to comment.