UserAgentTrait::setLessJsUserAgent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 2
c 2
b 1
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PiedWeb\Curl;
4
5
trait UserAgentTrait
6
{
7
    public string $desktopUserAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0';
8
9
    public string $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 string $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