DeviceDetector   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 57
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getClient() 0 3 1
A getModel() 0 3 1
A getDevice() 0 3 1
A __construct() 0 6 1
A getOs() 0 3 1
A getDeviceName() 0 3 1
A getBrand() 0 3 1
A getBrandName() 0 3 1
A getBot() 0 3 1
A getUserAgent() 0 3 1
1
<?php
2
3
namespace coderius\hitCounter\components\deviceDetect;
4
5
use  coderius\hitCounter\components\deviceDetect\IDeviceDetect;
6
use  yii;
7
use  yii\base\BaseObject;
8
use  yii\web\Request;
9
use  DeviceDetector\DeviceDetector as DD;
10
use  DeviceDetector\Parser\Device\DeviceParserAbstract;
11
use yii\base\Component;
12
13
class DeviceDetector extends  Component implements IDeviceDetect{
14
15
    private $detector;
16
17
    public function __construct(Request $request, $config = [])
18
    {
19
        $userAgent = $request->getUserAgent();
20
        $this->detector = new DD($userAgent);
21
        $this->detector->parse();
22
        parent::__construct($config);
23
        
24
    }
25
26
    public function getOs($attr = '')
27
    {
28
        return $this->detector->getOs();
29
    }
30
31
32
    public function getClient($attr = '')
33
    {
34
        return $this->detector->getClient($attr = '');
35
    }
36
37
    public function getDevice()
38
    {
39
        return $this->detector->getDevice();
40
    }
41
42
    public function getDeviceName()
43
    {
44
        return $this->detector->getDeviceName();
45
    }
46
47
    public function getBrand()
48
    {
49
        return $this->detector->getBrand();
50
    }
51
52
    public function getBrandName()
53
    {
54
        return $this->detector->getBrandName();
55
    }
56
    
57
    public function getModel()
58
    {
59
        return $this->detector->getModel();
60
    }
61
62
    public function getUserAgent()
63
    {
64
        return $this->detector->getUserAgent();
65
    }
66
67
    public function getBot()
68
    {
69
        return $this->detector->getBot();
70
    }
71
72
    
73
}