1 | <?php |
||
11 | class Device implements DeviceInterface |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * A list of required keys for the factory method. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | public static $requiredFields = array( |
||
20 | 'deviceType', |
||
21 | 'userAgent' |
||
22 | ); |
||
23 | |||
24 | /** |
||
25 | * One of the TYPE_* constants. |
||
26 | * |
||
27 | * @var int |
||
28 | */ |
||
29 | protected $type; |
||
30 | |||
31 | /** |
||
32 | * The 'User-Agent' header as a string. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $userAgent; |
||
37 | |||
38 | /** |
||
39 | * The model of this device, such as Samsung, Chromebook, iPhone, or ... |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $model; |
||
44 | |||
45 | /** |
||
46 | * Version of the particular model, such as 5S for the iPhone 5S. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $modelVersion; |
||
51 | |||
52 | /** |
||
53 | * The operating system, such as 'Windows' or 'iOS'. |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $operatingSystem; |
||
58 | |||
59 | /** |
||
60 | * The OS version. |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $operatingSystemVersion; |
||
65 | |||
66 | /** |
||
67 | * The browser. If this is a bot, then this value is populated with the bot identifier, such as |
||
68 | * "facebookexternalhit" for Facebook crawling or "GoogleBot" for the Google. |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $browser; |
||
73 | |||
74 | /** |
||
75 | * The version of the browser (or bot crawler). |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $browserVersion; |
||
80 | |||
81 | /** |
||
82 | * The vendor name for this device. |
||
83 | * |
||
84 | * @var string |
||
85 | */ |
||
86 | protected $vendor; |
||
87 | |||
88 | /** |
||
89 | * @param $userAgent |
||
90 | * @param $deviceType |
||
91 | * @param $deviceModel |
||
92 | * @param $deviceModelVersion |
||
93 | * @param $operatingSystemModel |
||
94 | * @param $operatingSystemVersion |
||
95 | * @param $browserModel |
||
96 | * @param $browserVersion |
||
97 | * @param $vendor |
||
98 | */ |
||
99 | public function __construct( |
||
120 | |||
121 | /** |
||
122 | * Retrieves the type of device. |
||
123 | * |
||
124 | * @return int |
||
125 | */ |
||
126 | public function getType() |
||
130 | |||
131 | public function getModel() |
||
135 | |||
136 | public function getModelVersion() |
||
140 | |||
141 | public function getOperatingSystem() |
||
145 | |||
146 | public function getOperatingSystemVersion() |
||
150 | |||
151 | public function getBrowser() |
||
155 | |||
156 | public function getBrowserVersion() |
||
160 | |||
161 | public function getVendor() |
||
165 | |||
166 | public function getUserAgent() |
||
170 | |||
171 | public function isMobile() |
||
175 | |||
176 | public function isDesktop() |
||
180 | |||
181 | public function isTablet() |
||
185 | |||
186 | public function isBot() |
||
190 | |||
191 | public function toArray() |
||
209 | |||
210 | /** |
||
211 | * @param array $prop An array of properties to create this device from. |
||
212 | * @return Device The device instance. |
||
213 | * @throws InvalidDeviceSpecificationException When insufficient properties are present to |
||
214 | * identify this device. |
||
215 | */ |
||
216 | public static function create(array $prop) |
||
245 | } |