Conditions | 8 |
Paths | 13 |
Total Lines | 56 |
Code Lines | 33 |
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 |
||
15 | public function run() |
||
16 | { |
||
17 | $exit = false; |
||
18 | $count = 0; |
||
19 | $numPaginator = 0; |
||
20 | $countProxyVirgin = rand(0, count($this->listOfVirginProxies) - 1); |
||
21 | $resultFinal = array(); |
||
22 | $totalOutProxy = 5; |
||
23 | $countOutProxy = 0; |
||
24 | |||
25 | while ($exit == false) { |
||
|
|||
26 | if ($count != 0) { |
||
27 | $numPaginator = 10 * $count; |
||
28 | } |
||
29 | |||
30 | $urlOfSearch = 'http://www.bing.com/search?q='.urlencode($this->commandData['dork']).'&filt=rf&first='.$numPaginator; |
||
31 | |||
32 | $this->output('Page '.$count."\n"); |
||
33 | |||
34 | if ($this->commandData['virginProxies']) { |
||
35 | $this->output('*'.$countProxyVirgin.'*'); |
||
36 | |||
37 | $this->output('&'.$this->listOfVirginProxies[$countProxyVirgin].'&'); |
||
38 | |||
39 | $body = Utils::getBodyByVirginProxies($urlOfSearch, $this->listOfVirginProxies[$countProxyVirgin], $this->proxy); |
||
40 | |||
41 | $arrLinks = Utils::getLinks($body); |
||
42 | |||
43 | //Check if next virgin proxy or repeat of 0 |
||
44 | if ($countProxyVirgin == count($this->listOfVirginProxies) - 1) { |
||
45 | $countProxyVirgin = 0; |
||
46 | } else { |
||
47 | ++$countProxyVirgin; |
||
48 | } |
||
49 | } else { |
||
50 | $body = Utils::getBody($urlOfSearch, $this->proxy); |
||
51 | |||
52 | $arrLinks = Utils::getLinks($body); |
||
53 | |||
54 | ++$countOutProxy; |
||
55 | } |
||
56 | |||
57 | $this->output("\n".$urlOfSearch."\n"); |
||
58 | |||
59 | $results = Utils::sanitazeLinks($arrLinks); |
||
60 | |||
61 | if ((count($results) == 0 && $body != 'repeat') || ($countOutProxy == $totalOutProxy)) { |
||
62 | $exit = true; |
||
63 | } |
||
64 | |||
65 | $resultFinal = array_merge($resultFinal, $results); |
||
66 | ++$count; |
||
67 | } |
||
68 | |||
69 | return $resultFinal; |
||
70 | } |
||
71 | } |
||
72 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.