Conditions | 13 |
Paths | 85 |
Total Lines | 81 |
Code Lines | 55 |
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 | $countError = 0; |
||
23 | |||
24 | $numberForUrl = $this->getNumberForUrl(); |
||
25 | |||
26 | while ($exit == false) { |
||
27 | switch ($count) { |
||
28 | case 0: |
||
29 | $numPaginator = 0; |
||
30 | break; |
||
31 | case 1: |
||
32 | $numPaginator = 30; |
||
33 | break; |
||
34 | case 2: |
||
35 | $numPaginator = 80; |
||
36 | break; |
||
37 | case 3: |
||
38 | $numPaginator = 130; |
||
39 | break; |
||
40 | case 4: |
||
41 | $numPaginator = 180; |
||
42 | break; |
||
43 | default: |
||
44 | $numPaginator = 230; |
||
45 | break; |
||
46 | |||
47 | } |
||
48 | |||
49 | $urlOfSearch = 'https://duckduckgo.com/d.js?q='.urlencode($this->commandData['dork']).'&ct=BR&ss_mkt=us&sp=1&l=wt-wt&vqd='.$numberForUrl.'&p=1&s='.$numPaginator; |
||
50 | |||
51 | $this->output('Page '.$count."\n"); |
||
52 | |||
53 | if ($this->commandData['virginProxies']) { |
||
54 | $body = Utils::getBodyByVirginProxies($urlOfSearch, $this->listOfVirginProxies[$countProxyVirgin], $this->proxy); |
||
55 | |||
56 | $arrLinks = $this->getLinks($body); |
||
57 | |||
58 | if ($this->checkReturnError($body)) { |
||
59 | $this->output("You has a problem with proxy, probaly you stress the engenier ...\n"); |
||
60 | --$count; |
||
61 | ++$countError; |
||
62 | if ($countError == 4) { |
||
63 | $exit = true; |
||
64 | } |
||
65 | } else { |
||
66 | $countError = 0; |
||
67 | } |
||
68 | |||
69 | //Check if next virgin proxy or repeat of 0 |
||
70 | if ($countProxyVirgin == count($this->listOfVirginProxies) - 1) { |
||
71 | $countProxyVirgin = 0; |
||
72 | } else { |
||
73 | ++$countProxyVirgin; |
||
74 | } |
||
75 | } else { |
||
76 | $body = Utils::getBody($urlOfSearch, $this->proxy); |
||
77 | |||
78 | $arrLinks = $this->getLinks($body); |
||
79 | } |
||
80 | |||
81 | $this->output("\n".$urlOfSearch."\n"); |
||
82 | |||
83 | $results = $this->sanitazeLinks($arrLinks); |
||
84 | |||
85 | if ((count($results) == 0 and $body != 'repeat')) { |
||
86 | $exit = true; |
||
87 | } |
||
88 | |||
89 | $resultFinal = array_merge($resultFinal, $results); |
||
90 | |||
91 | ++$count; |
||
92 | } |
||
93 | |||
94 | return $resultFinal; |
||
95 | } |
||
96 | |||
157 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.