| Conditions | 10 |
| Paths | 7 |
| Total Lines | 35 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 101 | private function validateSettings(): void |
||
| 102 | { |
||
| 103 | // If captcha is not enabled, there is no need to verify the settings |
||
| 104 | if (!$this->enabled) { |
||
| 105 | return; |
||
| 106 | } |
||
| 107 | |||
| 108 | if ($this->type === '' || !$this->isValidCaptchaType($this->type)) { |
||
| 109 | throw new InvalidCaptchaConfigurationException( |
||
| 110 | 'Invalid captcha type settings. Valid values are "hCaptcha" and "reCaptcha', |
||
| 111 | 1631962901 |
||
| 112 | ); |
||
| 113 | } |
||
| 114 | if ($this->apiScript === '' || !filter_var($this->apiScript, FILTER_VALIDATE_URL)) { |
||
| 115 | throw new InvalidCaptchaConfigurationException( |
||
| 116 | 'Invalid apiScript setting.', |
||
| 117 | 1631962907 |
||
| 118 | ); |
||
| 119 | } |
||
| 120 | if ($this->verificationServer === '' || !filter_var($this->verificationServer, FILTER_VALIDATE_URL)) { |
||
| 121 | throw new InvalidCaptchaConfigurationException( |
||
| 122 | 'Invalid verificationServer setting.', |
||
| 123 | 1631962990 |
||
| 124 | ); |
||
| 125 | } |
||
| 126 | if ($this->publicKey === '') { |
||
| 127 | throw new InvalidCaptchaConfigurationException( |
||
| 128 | 'Invalid publicKey/siteKey setting.', |
||
| 129 | 1631964323 |
||
| 130 | ); |
||
| 131 | } |
||
| 132 | if ($this->privateKey === '') { |
||
| 133 | throw new InvalidCaptchaConfigurationException( |
||
| 134 | 'Invalid privateKey/secretKey setting.', |
||
| 135 | 1631964328 |
||
| 136 | ); |
||
| 140 |