Skip to content

Commit 3403c4c

Browse files
committed
Removed the 2nd parameter, $fallback, from the match method
1 parent 6e20d0f commit 3403c4c

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
5151
use 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
6565
use 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
```

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
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",

src/UserAgentParser.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff 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
/**

tests/ExceptionMBStringTest.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)