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
|
3 |
|
public function __construct(Request $request, $config = []) |
18
|
|
|
{ |
19
|
3 |
|
$userAgent = $request->getUserAgent(); |
20
|
3 |
|
$this->detector = new DD($userAgent); |
21
|
3 |
|
$this->detector->parse(); |
22
|
3 |
|
parent::__construct($config); |
23
|
|
|
|
24
|
3 |
|
} |
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
|
|
|
} |