Skip to content

Commit

Permalink
Fixed some PHPStan recommendations.
Browse files Browse the repository at this point in the history
Updated dependencies.
  • Loading branch information
hexydec committed Oct 1, 2024
1 parent 697da28 commit d3029f9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/agentzero.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ protected static function getTokens(string $ua, array $single, array $ignore) :
* @return agentzero|false An agentzero object containing the parsed values of the input UA, or false if it could not be parsed
*/
public static function parse(string $ua) : agentzero|false {
$ua = \trim(\preg_replace('/\s{2,}/', ' ', $ua), ' "\'');
if (($config = config::get()) === null) {
if (($ua = \preg_replace('/\s{2,}/', ' ', $ua)) === null) {

} elseif (($tokens = self::getTokens($ua, $config['single'], $config['ignore'])) !== false) {
} elseif (($config = config::get()) === null) {

} elseif (($tokens = self::getTokens(\trim($ua, ' "\''), $config['single'], $config['ignore'])) !== false) {

// extract UA info
$browser = new \stdClass();
Expand Down
3 changes: 1 addition & 2 deletions src/mappings/crawlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public static function getApp(string $value, array $data = []) : array {
'duckduckgo-favicons-bot' => 'search',
'coccocbot-image' => 'search',
'coccocbot-web' => 'search',
'applebot' => 'ai',
'yandexbot' => 'search',
'mj12bot' => 'search',
'mail.ru_bot' => 'search',
Expand Down Expand Up @@ -182,7 +181,7 @@ public static function getApp(string $value, array $data = []) : array {
return [];
}

protected static function normaliseAppname(string $name) {
protected static function normaliseAppname(string $name) : string {
$find = ['_', '-', '+', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
$replace = [' ', ' ', '', ' A', ' B', ' C', ' D', ' E', ' F', ' G', ' H', ' I', ' J', ' K', ' L', ' M', ' N', ' O', ' P', ' Q', ' R', ' S', ' T', ' U', ' V', ' W', ' X', ' Y', ' Z'];
$name = \trim(\str_replace($find, $replace, $name));
Expand Down

0 comments on commit d3029f9

Please sign in to comment.