File tree Expand file tree Collapse file tree 4 files changed +49
-3
lines changed Expand file tree Collapse file tree 4 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,25 @@ The language method allows you to detect a user's language.
175
175
Identify::lang()->getLanguage()
176
176
```
177
177
178
+ ## Mobile Detection
179
+
180
+ The mobile method allows you to detect if user is on mobile.
181
+
182
+ ### Usage
183
+
184
+ ``` php
185
+ /**
186
+ * Returns true if any type of mobile device detected, including special ones
187
+ * @return boolean
188
+ */
189
+ Identify::mobile()->isMobile()
190
+
191
+ /**
192
+ * Return true if any type of tablet device is detected.
193
+ * @return boolean
194
+ */
195
+ Identify::mobile()->isTablet()
196
+ ```
178
197
179
198
## Contributing
180
199
Original file line number Diff line number Diff line change 12
12
"require" : {
13
13
"php" : " >=7.1.3" ,
14
14
"illuminate/support" : " ~5.7.0|~5.8.0" ,
15
- "sinergi/browser-detector" : " 6.1.*"
15
+ "sinergi/browser-detector" : " 6.1.*" ,
16
+ "mobiledetect/mobiledetectlib" : " ^2.8"
16
17
},
17
- "require-dev" : {
18
+ "require-dev" : {
18
19
"phpunit/phpunit" : " ~6.0.0" ,
19
20
"mockery/mockery" : " 0.9.*" ,
20
21
"scrutinizer/ocular" : " ~1.1" ,
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ class Identify {
30
30
*/
31
31
protected $ language ;
32
32
33
+ /**
34
+ * Store the mobile object
35
+ * @var object
36
+ */
37
+ protected $ mobile ;
38
+
33
39
/**
34
40
* Create an Instance of Browser and Os
35
41
*/
@@ -39,6 +45,7 @@ public function __construct()
39
45
$ this ->device = new Device ();
40
46
$ this ->browser = new Browser ();
41
47
$ this ->language = new Language ();
48
+ $ this ->mobile = new \Mobile_Detect ();
42
49
}
43
50
44
51
/**
@@ -81,4 +88,14 @@ public function lang() : Language
81
88
return $ this ->language ;
82
89
}
83
90
84
- }
91
+ /**
92
+ * Get all the methods applicable to Mobile detection
93
+ * e.g isMobile()
94
+ * @return \Mobile_Detect
95
+ */
96
+ public function mobile () : \Mobile_Detect
97
+ {
98
+ return $ this ->mobile ;
99
+ }
100
+
101
+ }
Original file line number Diff line number Diff line change @@ -65,4 +65,13 @@ public function testLanguageIsInitializedOnIdentifyConstruction()
65
65
{
66
66
$ this ->assertInstanceOf (Language::class, $ this ->identify ->lang ());
67
67
}
68
+
69
+ /**
70
+ * Test if Mobile returns bool
71
+ *
72
+ */
73
+ public function testMobileIsInitializedOnIdentifyConstruction ()
74
+ {
75
+ $ this ->assertInstanceOf (\Mobile_Detect::class, $ this ->identify ->mobile ());
76
+ }
68
77
}
You can’t perform that action at this time.
0 commit comments