| Conditions | 15 |
| Paths | 15 |
| Total Lines | 251 |
| Code Lines | 173 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 1 |
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 |
||
| 111 | private function configureSms(InputInterface $input, OutputInterface $output) { |
||
| 112 | $helper = $this->getHelper('question'); |
||
| 113 | |||
| 114 | $providerQuestion = new Question('Please choose a SMS provider (sipgate, websms, playsms, clockworksms, puzzelsms, ecallsms, voipms, voipbuster, huawei_e3531, spryng, sms77io, ovh, clickatellcentral, clicksend): ', 'websms'); |
||
| 115 | $provider = $helper->ask($input, $output, $providerQuestion); |
||
| 116 | |||
| 117 | /** @var SMSConfig $config */ |
||
| 118 | $config = $this->smsGateway->getConfig(); |
||
| 119 | switch ($provider) { |
||
| 120 | case 'websms': |
||
| 121 | $config->setProvider($provider); |
||
| 122 | /** @var WebSmsConfig $providerConfig */ |
||
| 123 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 124 | |||
| 125 | $usernameQuestion = new Question('Please enter your websms.de username: '); |
||
| 126 | $username = $helper->ask($input, $output, $usernameQuestion); |
||
| 127 | $passwordQuestion = new Question('Please enter your websms.de password: '); |
||
| 128 | $password = $helper->ask($input, $output, $passwordQuestion); |
||
| 129 | |||
| 130 | $providerConfig->setUser($username); |
||
| 131 | $providerConfig->setPassword($password); |
||
| 132 | |||
| 133 | break; |
||
| 134 | case 'sipgate': |
||
| 135 | $config->setProvider($provider); |
||
| 136 | /** @var SipGateConfig $providerConfig */ |
||
| 137 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 138 | |||
| 139 | $tokenIdQuestion = new Question('Please enter your sipgate token-id: '); |
||
| 140 | $tokenId = $helper->ask($input, $output, $tokenIdQuestion); |
||
| 141 | $accessTokenQuestion = new Question('Please enter your sipgate access token: '); |
||
| 142 | $accessToken = $helper->ask($input, $output, $accessTokenQuestion); |
||
| 143 | $webSmsExtensionQuestion = new Question('Please enter your sipgate web-sms extension: '); |
||
| 144 | $webSmsExtension = $helper->ask($input, $output, $webSmsExtensionQuestion); |
||
| 145 | |||
| 146 | $providerConfig->setTokenId($tokenId); |
||
| 147 | $providerConfig->setAccessToken($accessToken); |
||
| 148 | $providerConfig->setWebSmsExtension($webSmsExtension); |
||
| 149 | |||
| 150 | break; |
||
| 151 | case 'playsms': |
||
| 152 | $config->setProvider($provider); |
||
| 153 | /** @var PlaySMSConfig $providerConfig */ |
||
| 154 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 155 | |||
| 156 | $urlQuestion = new Question('Please enter your PlaySMS URL: '); |
||
| 157 | $url = $helper->ask($input, $output, $urlQuestion); |
||
| 158 | $usernameQuestion = new Question('Please enter your PlaySMS username: '); |
||
| 159 | $username = $helper->ask($input, $output, $usernameQuestion); |
||
| 160 | $passwordQuestion = new Question('Please enter your PlaySMS password: '); |
||
| 161 | $password = $helper->ask($input, $output, $passwordQuestion); |
||
| 162 | |||
| 163 | $providerConfig->setUrl($url); |
||
| 164 | $providerConfig->setUser($username); |
||
| 165 | $providerConfig->setPassword($password); |
||
| 166 | |||
| 167 | break; |
||
| 168 | case 'clockworksms': |
||
| 169 | $config->setProvider($provider); |
||
| 170 | /** @var ClockworkSMSConfig $providerConfig */ |
||
| 171 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 172 | |||
| 173 | $apitokenQuestion = new Question('Please enter your clockworksms api token: '); |
||
| 174 | $apitoken = $helper->ask($input, $output, $apitokenQuestion); |
||
| 175 | |||
| 176 | $providerConfig->setApiToken($apitoken); |
||
| 177 | |||
| 178 | break; |
||
| 179 | case 'puzzelsms': |
||
| 180 | $config->setProvider($provider); |
||
| 181 | |||
| 182 | /** @var PuzzelSMSConfig $providerConfig */ |
||
| 183 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 184 | |||
| 185 | $urlQuestion = new Question('Please enter your PuzzelSMS URL: '); |
||
| 186 | $url = $helper->ask($input, $output, $urlQuestion); |
||
| 187 | |||
| 188 | $usernameQuestion = new Question('Please enter your PuzzelSMS username: '); |
||
| 189 | $username = $helper->ask($input, $output, $usernameQuestion); |
||
| 190 | |||
| 191 | $passwordQuestion = new Question('Please enter your PuzzelSMS password: '); |
||
| 192 | $password = $helper->ask($input, $output, $passwordQuestion); |
||
| 193 | |||
| 194 | $serviceQuestion = new Question('Please enter your PuzzelSMS service ID: '); |
||
| 195 | $serviceId = $helper->ask($input, $output, $serviceQuestion); |
||
| 196 | |||
| 197 | $providerConfig->setUrl($url); |
||
| 198 | $providerConfig->setUser($username); |
||
| 199 | $providerConfig->setPassword($password); |
||
| 200 | $providerConfig->setServiceId($serviceId); |
||
| 201 | break; |
||
| 202 | case 'ecallsms': |
||
| 203 | $config->setProvider($provider); |
||
| 204 | /** @var EcallSMSConfig $providerConfig */ |
||
| 205 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 206 | |||
| 207 | $usernameQuestion = new Question('Please enter your eCall.ch username: '); |
||
| 208 | $username = $helper->ask($input, $output, $usernameQuestion); |
||
| 209 | $passwordQuestion = new Question('Please enter your eCall.ch password: '); |
||
| 210 | $password = $helper->ask($input, $output, $passwordQuestion); |
||
| 211 | $senderIdQuestion = new Question('Please enter your eCall.ch sender ID: '); |
||
| 212 | $senderId = $helper->ask($input, $output, $senderIdQuestion); |
||
| 213 | |||
| 214 | $providerConfig->setUser($username); |
||
| 215 | $providerConfig->setPassword($password); |
||
| 216 | $providerConfig->setSenderId($senderId); |
||
| 217 | break; |
||
| 218 | |||
| 219 | case 'voipms': |
||
| 220 | $config->setProvider($provider); |
||
| 221 | |||
| 222 | /** @var VoipMsConfig $providerConfig */ |
||
| 223 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 224 | |||
| 225 | $usernameQuestion = new Question('Please enter your VoIP.ms API username: '); |
||
| 226 | $username = $helper->ask($input, $output, $usernameQuestion); |
||
| 227 | |||
| 228 | $passwordQuestion = new Question('Please enter your VoIP.ms API password: '); |
||
| 229 | $password = $helper->ask($input, $output, $passwordQuestion); |
||
| 230 | |||
| 231 | $didQuestion = new Question('Please enter your VoIP.ms DID: '); |
||
| 232 | $did = $helper->ask($input, $output, $didQuestion); |
||
| 233 | |||
| 234 | $providerConfig->setUser($username); |
||
| 235 | $providerConfig->setPassword($password); |
||
| 236 | $providerConfig->setDid($did); |
||
| 237 | break; |
||
| 238 | |||
| 239 | case 'voipbuster': |
||
| 240 | $config->setProvider($provider); |
||
| 241 | |||
| 242 | /** @var VoipbusterConfig $providerConfig */ |
||
| 243 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 244 | |||
| 245 | $usernameQuestion = new Question('Please enter your Voipbuster API username: '); |
||
| 246 | $username = $helper->ask($input, $output, $usernameQuestion); |
||
| 247 | |||
| 248 | $passwordQuestion = new Question('Please enter your Voipbuster API password: '); |
||
| 249 | $password = $helper->ask($input, $output, $passwordQuestion); |
||
| 250 | |||
| 251 | $didQuestion = new Question('Please enter your Voipbuster DID: '); |
||
| 252 | $did = $helper->ask($input, $output, $didQuestion); |
||
| 253 | |||
| 254 | $providerConfig->setUser($username); |
||
| 255 | $providerConfig->setPassword($password); |
||
| 256 | $providerConfig->setDid($did); |
||
| 257 | break; |
||
| 258 | |||
| 259 | case 'huawei_e3531': |
||
| 260 | $config->setProvider($provider); |
||
| 261 | /** @var HuaweiE3531Config $providerConfig */ |
||
| 262 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 263 | |||
| 264 | $urlQuestion = new Question('Please enter the base URL of the Huawei E3531 stick: ', 'http://192.168.8.1/api'); |
||
| 265 | $url = $helper->ask($input, $output, $urlQuestion); |
||
| 266 | |||
| 267 | $providerConfig->setUrl($url); |
||
| 268 | break; |
||
| 269 | |||
| 270 | case 'spryng': |
||
| 271 | $config->setProvider($provider); |
||
| 272 | /** @var SpryngSMSConfig $providerConfig */ |
||
| 273 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 274 | |||
| 275 | $apitokenQuestion = new Question('Please enter your Spryng api token: '); |
||
| 276 | $apitoken = $helper->ask($input, $output, $apitokenQuestion); |
||
| 277 | |||
| 278 | $providerConfig->setApiToken($apitoken); |
||
| 279 | |||
| 280 | break; |
||
| 281 | |||
| 282 | case 'sms77io': |
||
| 283 | $config->setProvider($provider); |
||
| 284 | /** @var Sms77IoConfig $providerConfig */ |
||
| 285 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 286 | |||
| 287 | $apiKeyQuestion = new Question('Please enter your sms77.io API key: '); |
||
| 288 | $apiKey = $helper->ask($input, $output, $apiKeyQuestion); |
||
| 289 | |||
| 290 | $providerConfig->setApiKey($apiKey); |
||
| 291 | break; |
||
| 292 | |||
| 293 | case 'ovh': |
||
| 294 | $config->setProvider($provider); |
||
| 295 | |||
| 296 | /** @var OvhConfig $providerConfig */ |
||
| 297 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 298 | |||
| 299 | $endpointQ = new Question('Please enter the endpoint to use (ovh-eu, ovh-us, ovh-ca, soyoustart-eu, soyoustart-ca, kimsufi-eu, kimsufi-ca, runabove-ca): '); |
||
| 300 | $endpoint = $helper->ask($input, $output, $endpointQ); |
||
| 301 | |||
| 302 | $appKeyQ = new Question('Please enter your application key: '); |
||
| 303 | $appKey = $helper->ask($input, $output, $appKeyQ); |
||
| 304 | |||
| 305 | $appSecretQ = new Question('Please enter your application secret: '); |
||
| 306 | $appSecret = $helper->ask($input, $output, $appSecretQ); |
||
| 307 | |||
| 308 | $consumerKeyQ = new Question('Please enter your consumer key: '); |
||
| 309 | $consumerKey = $helper->ask($input, $output, $consumerKeyQ); |
||
| 310 | |||
| 311 | $accountQ = new Question('Please enter your account (sms-*****): '); |
||
| 312 | $account = $helper->ask($input, $output, $accountQ); |
||
| 313 | |||
| 314 | $senderQ = new Question('Please enter your sender: '); |
||
| 315 | $sender = $helper->ask($input, $output, $senderQ); |
||
| 316 | |||
| 317 | $providerConfig->setApplicationKey($appKey); |
||
| 318 | $providerConfig->setApplicationSecret($appSecret); |
||
| 319 | $providerConfig->setConsumerKey($consumerKey); |
||
| 320 | $providerConfig->setEndpoint($endpoint); |
||
| 321 | $providerConfig->setAccount($account); |
||
| 322 | $providerConfig->setSender($sender); |
||
| 323 | break; |
||
| 324 | |||
| 325 | case 'clickatellcentral': |
||
| 326 | $config->setProvider($provider); |
||
| 327 | /** @var ClickatellCentralConfig $providerConfig */ |
||
| 328 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 329 | |||
| 330 | $apiQuestion = new Question('Please enter your central.clickatell.com API-ID: '); |
||
| 331 | $api = $helper->ask($input, $output, $apiQuestion); |
||
| 332 | $usernameQuestion = new Question('Please enter your central.clickatell.com username: '); |
||
| 333 | $username = $helper->ask($input, $output, $usernameQuestion); |
||
| 334 | $passwordQuestion = new Question('Please enter your central.clickatell.com password: '); |
||
| 335 | $password = $helper->ask($input, $output, $passwordQuestion); |
||
| 336 | |||
| 337 | $providerConfig->setApi($api); |
||
| 338 | $providerConfig->setUser($username); |
||
| 339 | $providerConfig->setPassword($password); |
||
| 340 | break; |
||
| 341 | |||
| 342 | case 'clicksend': |
||
| 343 | $config->setProvider($provider); |
||
| 344 | /** @var ClickSendConfig $providerConfig */ |
||
| 345 | $providerConfig = $config->getProvider()->getConfig(); |
||
| 346 | |||
| 347 | $usernameQuestion = new Question('Please enter your clicksend.com username: '); |
||
| 348 | $username = $helper->ask($input, $output, $usernameQuestion); |
||
| 349 | $apiKeyQuestion = new Question('Please enter your clicksend.com API Key (or, if subuser, the password): '); |
||
| 350 | $apiKey = $helper->ask($input, $output, $apiKeyQuestion); |
||
| 351 | |||
| 352 | $providerConfig->setUser($username); |
||
| 353 | $providerConfig->setApiKey($apiKey); |
||
| 354 | |||
| 355 | break; |
||
| 356 | |||
| 357 | default: |
||
| 358 | $output->writeln("Invalid provider $provider"); |
||
| 359 | break; |
||
| 360 | } |
||
| 361 | return 0; |
||
| 362 | } |
||
| 376 |