Completed
Push — master ( cb6493...8e9bfe )
by Dev
04:15
created

UserAgentTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

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