UserAgentTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 46
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setDesktopUserAgent() 0 5 1
A setMobileUserAgent() 0 5 1
A setLessJsUserAgent() 0 5 1
1
<?php
2
3
namespace PiedWeb\Curl;
4
5
trait UserAgentTrait
6
{
7
    public $desktopUserAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0';
8
9
    public $mobileUserAgent = 'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36'
10
                              .' (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36';
11
12
    public $lessJsUserAgent = 'NokiaN70-1/5.0609.2.0.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1 '
13
                              .'UP.Link/6.3.1.13.0';
14
15
    abstract public function setUserAgent(string $ua);
16
17
    /**
18
     * An self::setUserAgent()'s alias to add an user-agent wich correspond to a Desktop PC.
19
     *
20
     * @return self
21
     */
22 24
    public function setDesktopUserAgent()
23
    {
24 24
        $this->setUserAgent($this->desktopUserAgent);
25
26 24
        return $this;
27
    }
28
29
    /**
30
     * An self::setUserAgent()'s alias to add an user-agent wich correspond to a mobile.
31
     *
32
     * @return self
33
     */
34 3
    public function setMobileUserAgent()
35
    {
36 3
        $this->setUserAgent($this->mobileUserAgent);
37
38 3
        return $this;
39
    }
40
41
    /**
42
     * An self::setUserAgent()'s alias to add an user-agent wich correspond to a webrowser without javascript.
43
     *
44
     * @return self
45
     */
46 3
    public function setLessJsUserAgent()
47
    {
48 3
        $this->setUserAgent($this->lessJsUserAgent);
49
50 3
        return $this;
51
    }
52
}
53