@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | case 'telegram': |
101 | 101 | $this->configureTelegram($input, $output); |
102 | 102 | return 0; |
103 | - case 'xmpp': |
|
104 | - $this->configureXMPP($input, $output); |
|
105 | - return 0; |
|
103 | + case 'xmpp': |
|
104 | + $this->configureXMPP($input, $output); |
|
105 | + return 0; |
|
106 | 106 | default: |
107 | 107 | $output->writeln("<error>Invalid gateway $gatewayName</error>"); |
108 | 108 | return; |
@@ -439,64 +439,64 @@ discard block |
||
439 | 439 | $config->setBotToken($token); |
440 | 440 | } |
441 | 441 | |
442 | - private function configureXMPP(InputInterface $input, OutputInterface $output) { |
|
443 | - $helper = $this->getHelper('question'); |
|
442 | + private function configureXMPP(InputInterface $input, OutputInterface $output) { |
|
443 | + $helper = $this->getHelper('question'); |
|
444 | 444 | $sender = ''; |
445 | 445 | while (empty($sender) or substr_count($sender,'@') !== 1): |
446 | - $senderQuestion = new Question('Please enter your sender XMPP-JID: '); |
|
447 | - $sender = $helper->ask($input, $output, $senderQuestion); |
|
446 | + $senderQuestion = new Question('Please enter your sender XMPP-JID: '); |
|
447 | + $sender = $helper->ask($input, $output, $senderQuestion); |
|
448 | 448 | if (empty($sender)) { |
449 | - $output->writeln("XMPP-JID must not be empty!"); |
|
449 | + $output->writeln("XMPP-JID must not be empty!"); |
|
450 | 450 | } |
451 | 451 | elseif (substr_count($sender,'@') !== 1) { |
452 | - $output->writeln("XMPP-JID not valid!"); |
|
452 | + $output->writeln("XMPP-JID not valid!"); |
|
453 | 453 | } |
454 | 454 | else { |
455 | - $username = explode('@',$sender)[0]; |
|
455 | + $username = explode('@',$sender)[0]; |
|
456 | 456 | } |
457 | 457 | endwhile; |
458 | - $output->writeln("Using $sender as XMPP-JID.\nUsing $username as username."); |
|
458 | + $output->writeln("Using $sender as XMPP-JID.\nUsing $username as username."); |
|
459 | 459 | $password = ''; |
460 | 460 | while (empty($password)): |
461 | 461 | $passwordQuestion = new Question('Please enter your sender XMPP password: '); |
462 | - $password = $helper->ask($input, $output, $passwordQuestion); |
|
462 | + $password = $helper->ask($input, $output, $passwordQuestion); |
|
463 | 463 | if (empty($password)) { |
464 | - $output->writeln("Password must not be empty!"); |
|
465 | - } |
|
464 | + $output->writeln("Password must not be empty!"); |
|
465 | + } |
|
466 | 466 | endwhile; |
467 | - $output->writeln("Password accepted."); |
|
468 | - $server = ''; |
|
469 | - while (empty($server)): |
|
470 | - $serverQuestion = new Question('Please enter full path to access REST/HTTP API: '); |
|
471 | - $server = $helper->ask($input, $output, $serverQuestion); |
|
472 | - if (empty($server)) { |
|
473 | - $output->writeln("API path must not be empty!"); |
|
474 | - } |
|
475 | - endwhile; |
|
476 | - $output->writeln("Using $server as full URL to access REST/HTTP API."); |
|
477 | - $method = 0; |
|
478 | - while (intval($method) < 1 or intval($method) > 2): |
|
467 | + $output->writeln("Password accepted."); |
|
468 | + $server = ''; |
|
469 | + while (empty($server)): |
|
470 | + $serverQuestion = new Question('Please enter full path to access REST/HTTP API: '); |
|
471 | + $server = $helper->ask($input, $output, $serverQuestion); |
|
472 | + if (empty($server)) { |
|
473 | + $output->writeln("API path must not be empty!"); |
|
474 | + } |
|
475 | + endwhile; |
|
476 | + $output->writeln("Using $server as full URL to access REST/HTTP API."); |
|
477 | + $method = 0; |
|
478 | + while (intval($method) < 1 or intval($method) > 2): |
|
479 | 479 | echo "Please enter 1 or 2 for XMPP sending option:\n"; |
480 | 480 | echo "(1) prosody with mod_rest\n"; |
481 | 481 | echo "(2) prosody with mod_post_msg\n"; |
482 | - $methodQuestion = new Question('Your choice: '); |
|
483 | - $method = $helper->ask($input, $output, $methodQuestion); |
|
484 | - endwhile; |
|
485 | - if ($method === "1") { |
|
486 | - $output->writeln("Using prosody with mod_rest as XMPP sending option."); |
|
487 | - } |
|
488 | - elseif ($method === "2") { |
|
489 | - $output->writeln("Using prosody with mod_post_msg as XMPP sending option."); |
|
490 | - } |
|
491 | - $output->writeln("XMPP Admin Configuration finished."); |
|
482 | + $methodQuestion = new Question('Your choice: '); |
|
483 | + $method = $helper->ask($input, $output, $methodQuestion); |
|
484 | + endwhile; |
|
485 | + if ($method === "1") { |
|
486 | + $output->writeln("Using prosody with mod_rest as XMPP sending option."); |
|
487 | + } |
|
488 | + elseif ($method === "2") { |
|
489 | + $output->writeln("Using prosody with mod_post_msg as XMPP sending option."); |
|
490 | + } |
|
491 | + $output->writeln("XMPP Admin Configuration finished."); |
|
492 | 492 | |
493 | 493 | /** @var XMPPConfig $config */ |
494 | - $config = $this->xmppGateway->getConfig(); |
|
494 | + $config = $this->xmppGateway->getConfig(); |
|
495 | 495 | |
496 | - $config->setSender($sender); |
|
496 | + $config->setSender($sender); |
|
497 | 497 | $config->setPassword($password); |
498 | 498 | $config->setServer($server); |
499 | 499 | $config->setUsername($username); |
500 | 500 | $config->setMethod($method); |
501 | - } |
|
501 | + } |
|
502 | 502 | } |
@@ -442,17 +442,17 @@ |
||
442 | 442 | private function configureXMPP(InputInterface $input, OutputInterface $output) { |
443 | 443 | $helper = $this->getHelper('question'); |
444 | 444 | $sender = ''; |
445 | - while (empty($sender) or substr_count($sender,'@') !== 1): |
|
445 | + while (empty($sender) or substr_count($sender, '@') !== 1): |
|
446 | 446 | $senderQuestion = new Question('Please enter your sender XMPP-JID: '); |
447 | 447 | $sender = $helper->ask($input, $output, $senderQuestion); |
448 | 448 | if (empty($sender)) { |
449 | 449 | $output->writeln("XMPP-JID must not be empty!"); |
450 | 450 | } |
451 | - elseif (substr_count($sender,'@') !== 1) { |
|
451 | + elseif (substr_count($sender, '@') !== 1) { |
|
452 | 452 | $output->writeln("XMPP-JID not valid!"); |
453 | 453 | } |
454 | 454 | else { |
455 | - $username = explode('@',$sender)[0]; |
|
455 | + $username = explode('@', $sender)[ 0 ]; |
|
456 | 456 | } |
457 | 457 | endwhile; |
458 | 458 | $output->writeln("Using $sender as XMPP-JID.\nUsing $username as username."); |
@@ -447,11 +447,9 @@ discard block |
||
447 | 447 | $sender = $helper->ask($input, $output, $senderQuestion); |
448 | 448 | if (empty($sender)) { |
449 | 449 | $output->writeln("XMPP-JID must not be empty!"); |
450 | - } |
|
451 | - elseif (substr_count($sender,'@') !== 1) { |
|
450 | + } elseif (substr_count($sender,'@') !== 1) { |
|
452 | 451 | $output->writeln("XMPP-JID not valid!"); |
453 | - } |
|
454 | - else { |
|
452 | + } else { |
|
455 | 453 | $username = explode('@',$sender)[0]; |
456 | 454 | } |
457 | 455 | endwhile; |
@@ -484,8 +482,7 @@ discard block |
||
484 | 482 | endwhile; |
485 | 483 | if ($method === "1") { |
486 | 484 | $output->writeln("Using prosody with mod_rest as XMPP sending option."); |
487 | - } |
|
488 | - elseif ($method === "2") { |
|
485 | + } elseif ($method === "2") { |
|
489 | 486 | $output->writeln("Using prosody with mod_post_msg as XMPP sending option."); |
490 | 487 | } |
491 | 488 | $output->writeln("XMPP Admin Configuration finished."); |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | /** @var TelegramGateway */ |
43 | 43 | private $telegramGateway; |
44 | 44 | |
45 | - /** @var XMPPGateway */ |
|
46 | - private $xmppGateway; |
|
45 | + /** @var XMPPGateway */ |
|
46 | + private $xmppGateway; |
|
47 | 47 | |
48 | 48 | public function __construct(SignalGateway $signalGateway, |
49 | 49 | SMSGateway $smsGateway, |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | $output->writeln('SMS gateway: ' . ($smsConfigured ? 'configured' : 'not configured')); |
64 | 64 | $telegramConfigured = $this->telegramGateway->getConfig()->isComplete(); |
65 | 65 | $output->writeln('Telegram gateway: ' . ($telegramConfigured ? 'configured' : 'not configured')); |
66 | - $xmppConfigured = $this->xmppGateway->getConfig()->isComplete(); |
|
67 | - $output->writeln('XMPP gateway: ' . ($xmppConfigured ? 'configured' : 'not configured')); |
|
66 | + $xmppConfigured = $this->xmppGateway->getConfig()->isComplete(); |
|
67 | + $output->writeln('XMPP gateway: ' . ($xmppConfigured ? 'configured' : 'not configured')); |
|
68 | 68 | return 0; |
69 | 69 | } |
70 | 70 | } |
@@ -58,13 +58,13 @@ |
||
58 | 58 | |
59 | 59 | protected function execute(InputInterface $input, OutputInterface $output) { |
60 | 60 | $signalConfigured = $this->signalGateway->getConfig()->isComplete(); |
61 | - $output->writeln('Signal gateway: ' . ($signalConfigured ? 'configured' : 'not configured')); |
|
61 | + $output->writeln('Signal gateway: '.($signalConfigured ? 'configured' : 'not configured')); |
|
62 | 62 | $smsConfigured = $this->smsGateway->getConfig()->isComplete(); |
63 | - $output->writeln('SMS gateway: ' . ($smsConfigured ? 'configured' : 'not configured')); |
|
63 | + $output->writeln('SMS gateway: '.($smsConfigured ? 'configured' : 'not configured')); |
|
64 | 64 | $telegramConfigured = $this->telegramGateway->getConfig()->isComplete(); |
65 | - $output->writeln('Telegram gateway: ' . ($telegramConfigured ? 'configured' : 'not configured')); |
|
65 | + $output->writeln('Telegram gateway: '.($telegramConfigured ? 'configured' : 'not configured')); |
|
66 | 66 | $xmppConfigured = $this->xmppGateway->getConfig()->isComplete(); |
67 | - $output->writeln('XMPP gateway: ' . ($xmppConfigured ? 'configured' : 'not configured')); |
|
67 | + $output->writeln('XMPP gateway: '.($xmppConfigured ? 'configured' : 'not configured')); |
|
68 | 68 | return 0; |
69 | 69 | } |
70 | 70 | } |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | /** @var TelegramProvider */ |
38 | 38 | private $telegramProvider; |
39 | 39 | |
40 | - /** @var XMPPProvider */ |
|
41 | - private $xmppProvider; |
|
40 | + /** @var XMPPProvider */ |
|
41 | + private $xmppProvider; |
|
42 | 42 | |
43 | 43 | public function __construct(SignalProvider $signalProvider, |
44 | 44 | SmsProvider $smsProvider, |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->signalProvider = $signalProvider; |
48 | 48 | $this->smsProvider = $smsProvider; |
49 | 49 | $this->telegramProvider = $telegramProvider; |
50 | - $this->xmppProvider = $xmppProvider; |
|
50 | + $this->xmppProvider = $xmppProvider; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | case 'telegram': |
61 | 61 | return $this->telegramProvider; |
62 | 62 | case 'xmpp': |
63 | - return $this->xmppProvider; |
|
63 | + return $this->xmppProvider; |
|
64 | 64 | default: |
65 | 65 | throw new InvalidSmsProviderException(); |
66 | 66 | } |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | $url = 'https://api.smsapi.com/sms.do'; |
57 | 57 | |
58 | 58 | $params = array( |
59 | - 'to' => $identifier, //destination number |
|
60 | - 'from' => $sender, //sendername made in https://ssl.smsapi.com/sms_settings/sendernames |
|
61 | - 'message' => $message, //message content |
|
62 | - 'format' => 'json', //get response in json format |
|
59 | + 'to' => $identifier, //destination number |
|
60 | + 'from' => $sender, //sendername made in https://ssl.smsapi.com/sms_settings/sendernames |
|
61 | + 'message' => $message, //message content |
|
62 | + 'format' => 'json', //get response in json format |
|
63 | 63 | ); |
64 | 64 | |
65 | 65 | try { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | curl_close($c); |
81 | 81 | $responseData = json_decode($content->getBody(), true); |
82 | 82 | |
83 | - if ($responseData['count'] !== 1) { |
|
83 | + if ($responseData[ 'count' ] !== 1) { |
|
84 | 84 | throw new SmsTransmissionException(); |
85 | 85 | } |
86 | 86 | } catch (Exception $ex) { |