File tree Expand file tree Collapse file tree 4 files changed +8
-35
lines changed Expand file tree Collapse file tree 4 files changed +8
-35
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ var_dump($parser->stripVersion());
4646/* googlebot */
4747```
4848
49- ### Find different groups the User-Agent belongs to.
49+ ### Find different groups the User-Agent belongs to
5050``` php
5151use vipnytt\UserAgentParser;
5252
@@ -60,11 +60,11 @@ var_dump($parser->export());
6060```
6161
6262### Determine the correct group
63- Determine the correct group of records by finding the group with the most specific user-agent that still matches.
63+ Determine the correct group of records by finding the group with the most specific user-agent that still matches
6464``` php
6565use vipnytt\UserAgentParser;
6666
6767$parser = new UserAgentParser('googlebot-news');
68- var_dump($parser->match(['googlebot/2.1', 'googlebot-images','googlebot']));
68+ var_dump($parser->match(['googlebot/2.1', 'googlebot-images', 'googlebot']));
6969/* googlebot */
7070```
Original file line number Diff line number Diff line change 1818 "minimum-stability" : " dev" ,
1919 "prefer-stable" : true ,
2020 "require" : {
21- "php" : " >=5.4.0"
21+ "php" : " >=5.4.0" ,
22+ "ext-mbstring" : " *"
2223 },
2324 "require-dev" : {
2425 "phpunit/phpunit" : " >=4.0" ,
Original file line number Diff line number Diff line change @@ -21,11 +21,7 @@ class UserAgentParser
2121 */
2222 public function __construct ($ userAgent )
2323 {
24- if (!extension_loaded ('mbstring ' )) {
25- throw new Exception ('The extension `mbstring` must be installed and loaded for this library ' );
26- }
2724 mb_detect_encoding ($ userAgent );
28-
2925 $ this ->userAgent = mb_strtolower (trim ($ userAgent ));
3026 $ this ->explode ();
3127 }
@@ -61,20 +57,19 @@ public function stripVersion()
6157
6258 /**
6359 * Find matching User-Agent
64- * Selects the best matching from an array, or $fallback if none matches
60+ * Selects the best matching from an array, or false if none matches
6561 *
6662 * @param array $array
67- * @param string|null $fallback
6863 * @return string|false
6964 */
70- public function match ($ array, $ fallback = null )
65+ public function match ($ array )
7166 {
7267 foreach ($ this ->groups as $ userAgent ) {
7368 if (in_array ($ userAgent , array_map ('mb_strtolower ' , $ array ))) {
7469 return $ userAgent ;
7570 }
7671 }
77- return isset ( $ fallback ) ? $ fallback : false ;
72+ return false ;
7873 }
7974
8075 /**
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments