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