| Conditions | 11 |
| Paths | 8 |
| Total Lines | 79 |
| Code Lines | 43 |
| 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 |
||
| 49 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 50 | { |
||
| 51 | $timeStart = microtime(true); |
||
| 52 | $listShow = 'all'; |
||
| 53 | |||
| 54 | $symfonyStyle = new SymfonyStyle($input, $output); |
||
| 55 | |||
| 56 | /** @var ProxyBonanza $proxyBonanza */ |
||
| 57 | $proxyBonanza = $this->getContainer()->get('wowapps.proxybonanza'); |
||
| 58 | |||
| 59 | $symfonyStyle->title(' P R O X Y B O N A N Z A L I S T '); |
||
| 60 | |||
| 61 | if ($input->getOption('show') && in_array(strtolower($input->getOption('show')), self::ALLOWED_OPTION_SHOW)) { |
||
| 62 | $listShow = strtolower($input->getOption('show')); |
||
| 63 | } |
||
| 64 | |||
| 65 | if ($listShow == 'all' || $listShow == 'local') { |
||
| 66 | $symfonyStyle->section(' List of local proxies: '); |
||
| 67 | |||
| 68 | $pbPlans = $proxyBonanza->getLocalPlans(); |
||
| 69 | $pbPlans = $proxyBonanza->getLocalPlansProxies($pbPlans); |
||
| 70 | |||
| 71 | $header = ['ip', 'http port', 'socks port', 'login', 'password', 'region']; |
||
| 72 | |||
| 73 | $body = []; |
||
| 74 | |||
| 75 | /** @var Plan $pbPlan */ |
||
| 76 | foreach ($pbPlans as $pbPlan) { |
||
| 77 | $symfonyStyle->text(sprintf(' Proxy plan #%d local proxies:', $pbPlan->getId())); |
||
| 78 | |||
| 79 | /** @var Proxy $proxy */ |
||
| 80 | foreach ($pbPlan->getProxy() as $proxy) { |
||
| 81 | $body[] = [ |
||
| 82 | $proxy->getProxyIp(), |
||
| 83 | $proxy->getProxyPortHttp(), |
||
| 84 | $proxy->getProxyPortSocks(), |
||
| 85 | $proxy->getPlan()->getLogin(), |
||
| 86 | $proxy->getPlan()->getPassword(), |
||
| 87 | $proxy->getProxyRegionCountryName() |
||
| 88 | ]; |
||
| 89 | } |
||
| 90 | |||
| 91 | $symfonyStyle->table($header, $body); |
||
| 92 | } |
||
| 93 | } |
||
| 94 | |||
| 95 | if ($listShow == 'all' || $listShow == 'remote') { |
||
| 96 | $symfonyStyle->section(' List of remote proxies: '); |
||
| 97 | |||
| 98 | $pbPlans = $proxyBonanza->getRemotePlans(); |
||
| 99 | $pbPlans = $proxyBonanza->getRemotePacks($pbPlans); |
||
| 100 | |||
| 101 | $header = ['ip', 'http port', 'socks port', 'login', 'password', 'region']; |
||
| 102 | |||
| 103 | $body = []; |
||
| 104 | |||
| 105 | /** @var Plan $pbPlan */ |
||
| 106 | foreach ($pbPlans as $pbPlan) { |
||
| 107 | $symfonyStyle->text(sprintf(' Proxy plan #%d remote proxies:', $pbPlan->getId())); |
||
| 108 | |||
| 109 | /** @var Proxy $proxy */ |
||
| 110 | foreach ($pbPlan->getProxy() as $proxy) { |
||
| 111 | $body[] = [ |
||
| 112 | $proxy->getProxyId(), |
||
| 113 | $proxy->getProxyPortHttp(), |
||
| 114 | $proxy->getProxyPortSocks(), |
||
| 115 | $proxy->getPlan()->getLogin(), |
||
| 116 | $proxy->getPlan()->getPassword(), |
||
| 117 | $proxy->getProxyRegionCountryName() |
||
| 118 | ]; |
||
| 119 | } |
||
| 120 | |||
| 121 | $symfonyStyle->table($header, $body); |
||
| 122 | } |
||
| 123 | } |
||
| 124 | |||
| 125 | $symfonyStyle->note(sprintf('Command is executed in %s seconds', $this->formatSpentTime($timeStart))); |
||
| 126 | |||
| 127 | $symfonyStyle->newLine(2); |
||
| 128 | } |
||
| 130 |