MobileDetect::isComputer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PragmaRX\Tracker\Support;
4
5
use Jenssegers\Agent\Agent;
6
7
class MobileDetect extends Agent
8
{
9
    /**
10
     * Detect kind, model and mobility.
11
     *
12
     * @return array
13
     */
14
    public function detectDevice()
15
    {
16
        return [
17
            'kind'      => $this->getDeviceKind(),
18
            'model'     => $this->device(),
19
            'is_mobile' => $this->isMobile(),
20
            'is_robot'  => $this->isRobot(),
21
        ];
22
    }
23
24
    /**
25
     * Get the kind of device.
26
     *
27
     * @internal param $mobile
28
     *
29
     * @return string
30
     */
31
    public function getDeviceKind()
32
    {
33
        $kind = 'unavailable';
34
35
        if ($this->isTablet()) {
36
            $kind = 'Tablet';
37
        } elseif ($this->isPhone()) {
38
            $kind = 'Phone';
39
        } elseif ($this->isComputer()) {
40
            $kind = 'Computer';
41
        }
42
43
        return $kind;
44
    }
45
46
    /**
47
     * Is this a phone?
48
     *
49
     * @return bool
50
     */
51
    public function isPhone($userAgent = null, $httpHeaders = null)
52
    {
53
        return !$this->isTablet() && !$this->isComputer();
54
    }
55
56
    /**
57
     * Is this a computer?
58
     *
59
     * @return bool
60
     */
61
    public function isComputer()
62
    {
63
        return !$this->isMobile();
64
    }
65
}
66