Bing   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 59
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 56 8
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: lenon
5
 * Date: 23/04/16
6
 * Time: 01:43.
7
 */
8
9
namespace Aszone\SearchHacking\Engines;
10
11
use Aszone\SearchHacking\Utils;
12
13
class Bing extends Engine
14
{
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) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
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);
0 ignored issues
show
Documentation introduced by
$arrLinks is of type object<Symfony\Component\DomCrawler\Crawler>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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