| Conditions | 6 | 
| Paths | 8 | 
| Total Lines | 66 | 
| Code Lines | 35 | 
| 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 | ||
| 45 | protected function execute(InputInterface $input, OutputInterface $output) | ||
| 46 |     { | ||
| 47 | $timeStart = microtime(true); | ||
| 48 | |||
| 49 | /** @var ProxyBonanza $proxyBonanza */ | ||
| 50 |         $proxyBonanza = $this->getContainer()->get('wowapps.proxybonanza'); | ||
| 51 | |||
| 52 | $symfonyStyle = new SymfonyStyle($input, $output); | ||
| 53 | |||
| 54 | |||
| 55 |         $symfonyStyle->title(' P R O X Y   B O N A N Z A   T E S T '); | ||
| 56 | |||
| 57 | $pbPlans = $proxyBonanza->getLocalPlans(); | ||
| 58 | $pbPlans = $proxyBonanza->getLocalPlansProxies($pbPlans); | ||
| 59 | |||
| 60 | $brokenProxies = new \ArrayObject(); | ||
| 61 | |||
| 62 | /** @var Plan $pbPlan */ | ||
| 63 |         foreach ($pbPlans as $pbPlan) { | ||
| 64 |             $symfonyStyle->section(sprintf(' Start testing local proxies of plan #%d', $pbPlan->getId())); | ||
| 65 | |||
| 66 | $symfonyStyle->createProgressBar(); | ||
| 67 | $symfonyStyle->progressStart($pbPlan->getPackageHowmanyIps()); | ||
| 68 | |||
| 69 | /** @var Proxy $proxy */ | ||
| 70 |             foreach ($pbPlan->getProxy() as $proxy) { | ||
| 71 |                 if (!$proxyBonanza->testProxyConnection($proxy)) { | ||
| 72 | $brokenProxies->append($proxy); | ||
| 73 | } | ||
| 74 | |||
| 75 | $symfonyStyle->progressAdvance(1); | ||
| 76 | } | ||
| 77 | |||
| 78 | $symfonyStyle->progressFinish(); | ||
| 79 | } | ||
| 80 | |||
| 81 |         if (!$brokenProxies->count()) { | ||
| 82 |             $symfonyStyle->success('All proxies works!'); | ||
| 83 |         } else { | ||
| 84 |             $symfonyStyle->warning(sprintf('%d local proxies doesn\'t work!', $brokenProxies->count())); | ||
| 85 | |||
| 86 | $header = [ | ||
| 87 | 'ip', | ||
| 88 | 'port', | ||
| 89 | 'login', | ||
| 90 | 'password' | ||
| 91 | ]; | ||
| 92 | |||
| 93 | $body = []; | ||
| 94 | |||
| 95 | /** @var Proxy $brokenProxy */ | ||
| 96 |             foreach ($brokenProxies as $brokenProxy) { | ||
| 97 | $body[] = [ | ||
| 98 | $brokenProxy->getProxyIp(), | ||
| 99 | $brokenProxy->getProxyPortHttp(), | ||
| 100 | $brokenProxy->getPlan()->getLogin(), | ||
| 101 | $brokenProxy->getPlan()->getPassword() | ||
| 102 | ]; | ||
| 103 | } | ||
| 104 | |||
| 105 | $symfonyStyle->table($header, $body); | ||
| 106 | } | ||
| 107 | |||
| 108 |         $symfonyStyle->note(sprintf('Command is executed in %s seconds', $this->formatSpentTime($timeStart))); | ||
| 109 | |||
| 110 | $symfonyStyle->newLine(2); | ||
| 111 | } | ||
| 113 |