Test Failed
Push — master ( 138499...684014 )
by Dev
02:21
created

ConfSearchTrait::setUserAgent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace rOpenDev\Google;
4
5
trait ConfSearchTrait
6
{
7
    // =======
8
    // Conf var
9
    // =======
10
11
    /** @var string Contain the string query we will ask to Google Search * */
12
    protected $q;
13
14
    /** @var int Max number of result pages we want to extract * */
15
    protected $nbrPage = 1;
16
17
    /** @var array */
18
    protected $result = [];
19
20
    /** @var string Contain the Google TLD we want to query * */
21
    protected $tld = 'com';
22
23
    /** @var string Contain the language we want to send via HTTP Header Accept-Language (language[-local], eg. : en-US) * */
24
    protected $language = 'en-US';
25
26
    /** @var array Google Search URLs parameters (Eg. : hl => en) * */
27
    protected $parameters = [];
28
29
    /** @var string Contain http proxy settings * */
30
    protected $proxy;
31
32
    /** @var bool If the request need to emule a mobile * */
33
    protected $mobile = false;
34
35
    /** @var string Contain the user-agent we will send via HTTP Headers * */
36
    protected $userAgent;
37
38
    public function __construct(string $kw)
39
    {
40
        $this->q = $kw;
41
    }
42
43
    public function setMobile($bool)
44
    {
45
        $this->mobile = $bool;
46
47
        return $this;
48
    }
49
50
    public function setTld(string $tld)
51
    {
52
        $this->tld = $tld;
53
54
        return $this;
55
    }
56
57
    public function setLanguage(string $language)
58
    {
59
        $this->language = $language;
60
61
        return $this;
62
    }
63
64
    public function setParameter($k, $v)
65
    {
66
        $this->parameters[$k] = $v;
67
68
        return $this;
69
    }
70
71
    public function setNbrPage(int $nbr)
72
    {
73
        $this->nbrPage = $nbr;
74
75
        return $this;
76
    }
77
78
    public function setProxy($proxy)
79
    {
80
        $this->proxy = $proxy;
81
82
        return $this;
83
    }
84
85
    /**
86
     * Si Aucun user-agent n'est précisé avant la requête, le script chargera l'user-agent par défault
87
     * de la class curlRequest (setDestkopUserAgent).
88
     */
89
    public function setUserAgent($ua)
90
    {
91
        $this->userAgent = $ua;
92
93
        return $this;
94
    }
95
}
96