GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 794dfa...f087a3 )
by Martin
05:40
created

UserAgent::isMobile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
namespace UserAgentParser\Model;
3
4
/**
5
 * User agent model
6
 *
7
 * @author Martin Keckeis <[email protected]>
8
 * @license MIT
9
 */
10
class UserAgent
11
{
12
    /**
13
     * @var Browser
14
     */
15
    private $browser;
16
17
    /**
18
     * @var RenderingEngine
19
     */
20
    private $renderingEngine;
21
22
    /**
23
     * @var OperatingSystem
24
     */
25
    private $operatingSystem;
26
27
    /**
28
     * @var Device
29
     */
30
    private $device;
31
32
    /**
33
     * @var Bot
34
     */
35
    private $bot;
36
37
    /**
38
     * @var mixed
39
     */
40
    private $providerResultRaw;
41
42 9
    public function __construct()
43
    {
44 9
        $this->browser         = new Browser();
45 9
        $this->renderingEngine = new RenderingEngine();
46 9
        $this->operatingSystem = new OperatingSystem();
47 9
        $this->device          = new Device();
48 9
        $this->bot             = new Bot();
49 9
    }
50
51
    /**
52
     * @param Browser $browser
53
     */
54 1
    public function setBrowser(Browser $browser)
55
    {
56 1
        $this->browser = $browser;
57 1
    }
58
59
    /**
60
     * @return Browser
61
     */
62 2
    public function getBrowser()
63
    {
64 2
        return $this->browser;
65
    }
66
67
    /**
68
     * @param RenderingEngine $renderingEngine
69
     */
70 1
    public function setRenderingEngine(RenderingEngine $renderingEngine)
71
    {
72 1
        $this->renderingEngine = $renderingEngine;
73 1
    }
74
75
    /**
76
     * @return RenderingEngine
77
     */
78 2
    public function getRenderingEngine()
79
    {
80 2
        return $this->renderingEngine;
81
    }
82
83
    /**
84
     * @param OperatingSystem $operatingSystem
85
     */
86 1
    public function setOperatingSystem(OperatingSystem $operatingSystem)
87
    {
88 1
        $this->operatingSystem = $operatingSystem;
89 1
    }
90
91
    /**
92
     * @return OperatingSystem
93
     */
94 2
    public function getOperatingSystem()
95
    {
96 2
        return $this->operatingSystem;
97
    }
98
99
    /**
100
     * @param Device $device
101
     */
102 1
    public function setDevice(Device $device)
103
    {
104 1
        $this->device = $device;
105 1
    }
106
107
    /**
108
     * @return Device
109
     */
110 3
    public function getDevice()
111
    {
112 3
        return $this->device;
113
    }
114
115
    /**
116
     * @param Bot $bot
117
     */
118 1
    public function setBot(Bot $bot)
119
    {
120 1
        $this->bot = $bot;
121 1
    }
122
123
    /**
124
     * @return Bot
125
     */
126 3
    public function getBot()
127
    {
128 3
        return $this->bot;
129
    }
130
131
    /**
132
     * 
133
     * @return boolean
134
     */
135 1
    public function isBot()
136
    {
137 1
        if ($this->getBot()->getIsBot() === true) {
138 1
            return true;
139
        }
140
141 1
        return false;
142
    }
143
144
    /**
145
     * 
146
     * @return boolean
147
     */
148 1
    public function isMobile()
149
    {
150 1
        if ($this->getDevice()->getIsMobile() === true) {
151 1
            return true;
152
        }
153
154 1
        return false;
155
    }
156
157
    /**
158
     * @param mixed $providerResultRaw
159
     */
160 1
    public function setProviderResultRaw($providerResultRaw)
161
    {
162 1
        $this->providerResultRaw = $providerResultRaw;
163 1
    }
164
165
    /**
166
     * @return mixed
167
     */
168 2
    public function getProviderResultRaw()
169
    {
170 2
        return $this->providerResultRaw;
171
    }
172
173
    /**
174
     * @return array
175
     */
176 1
    public function toArray($includeResultRaw = false)
177
    {
178
        $data = [
179 1
            'browser'          => $this->getBrowser()->toArray(),
180 1
            'renderingEngine'  => $this->getRenderingEngine()->toArray(),
181 1
            'operatingSystem'  => $this->getOperatingSystem()->toArray(),
182 1
            'device'           => $this->getDevice()->toArray(),
183 1
            'bot'              => $this->getBot()->toArray(),
184
        ];
185
186
        // should be only used for debug
187 1
        if ($includeResultRaw === true) {
188 1
            $data['providerResultRaw'] = $this->getProviderResultRaw();
189
        }
190
191 1
        return $data;
192
    }
193
}
194