| Conditions | 2 |
| Paths | 2 |
| Total Lines | 54 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 28 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 29 | { |
||
| 30 | /** @var SlackBot $slackBot */ |
||
| 31 | $slackBot = $this->getContainer()->get('wowapps.slackbot'); |
||
| 32 | $slackBotConfig = $slackBot->getConfig(); |
||
| 33 | |||
| 34 | $symfonyStyle = new SymfonyStyle($input, $output); |
||
| 35 | |||
| 36 | echo PHP_EOL; |
||
| 37 | $output->writeln('<bg=blue;options=bold;fg=white> </>'); |
||
| 38 | $output->writeln('<bg=blue;options=bold;fg=white> S L A C K B O T T E S T </>'); |
||
| 39 | $output->writeln('<bg=blue;options=bold;fg=white> </>'); |
||
| 40 | echo PHP_EOL; |
||
| 41 | |||
| 42 | $symfonyStyle->section('SlackBot general settings'); |
||
| 43 | |||
| 44 | $symfonyStyle->table( |
||
| 45 | ['api url'], |
||
| 46 | [[$slackBotConfig['api_url']]] |
||
| 47 | ); |
||
| 48 | |||
| 49 | $symfonyStyle->table( |
||
| 50 | ['default icon'], |
||
| 51 | [[$slackBotConfig['default_icon']]] |
||
| 52 | ); |
||
| 53 | |||
| 54 | $symfonyStyle->table( |
||
| 55 | ['default recipient'], |
||
| 56 | [[$slackBotConfig['default_channel']]] |
||
| 57 | ); |
||
| 58 | |||
| 59 | $symfonyStyle->section('SlackBot quote colors'); |
||
| 60 | |||
| 61 | $symfonyStyle->table( |
||
| 62 | ['default', 'info', 'warning', 'success', 'danger'], |
||
| 63 | [ |
||
| 64 | [ |
||
| 65 | $slackBotConfig['quote_color']['default'], |
||
| 66 | $slackBotConfig['quote_color']['info'], |
||
| 67 | $slackBotConfig['quote_color']['warning'], |
||
| 68 | $slackBotConfig['quote_color']['success'], |
||
| 69 | $slackBotConfig['quote_color']['danger'] |
||
| 70 | ] |
||
| 71 | ] |
||
| 72 | ); |
||
| 73 | |||
| 74 | $symfonyStyle->section('Sending short message...'); |
||
| 75 | |||
| 76 | if ($this->sendTestMessage($slackBot)) { |
||
| 77 | $symfonyStyle->success('Message sent successfully'); |
||
| 78 | } else { |
||
| 79 | $symfonyStyle->error('Message not sent'); |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 115 |