Completed
Pull Request — master (#1)
by Konstantin
12:17
created

UserAgentTrait::setDesktopUserAgent()   A

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 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PiedWeb\Curl;
4
5
trait UserAgentTrait
6
{
7
    /**
8
     * An self::setUserAgent()'s alias to add an user-agent wich correspond to a Desktop PC.
9
     *
10
     * @return self
11
     */
12 5
    public function setDesktopUserAgent()
13
    {
14 5
        $this->setUserAgent('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0');
0 ignored issues
show
Bug introduced by
It seems like setUserAgent() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        $this->/** @scrutinizer ignore-call */ 
15
               setUserAgent('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0');
Loading history...
15
16 5
        return $this;
17
    }
18
19
    /**
20
     * An self::setUserAgent()'s alias to add an user-agent wich correspond to a mobile.
21
     *
22
     * @return self
23
     */
24
    public function setMobileUserAgent()
25
    {
26
        $this->setUserAgent('Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36'
27
            .' (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36');
28
29
        return $this;
30
    }
31
32
    /**
33
     * An self::setUserAgent()'s alias to add an user-agent wich correspond to a webrowser without javascript.
34
     *
35
     * @return self
36
     */
37
    public function setLessJsUserAgent()
38
    {
39
        $this->setUserAgent('NokiaN70-1/5.0609.2.0.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1 '
40
            .'UP.Link/6.3.1.13.0');
41
42
        return $this;
43
    }
44
}
45