From e22c7be05f475b44d0e6ecd76acf1617a2efef85 Mon Sep 17 00:00:00 2001 From: Benjamin Bellamy Date: Sat, 28 Nov 2020 11:54:05 +0100 Subject: [PATCH] feat: add getName() function --- .gitignore | 1 + src/UserAgentsRSSGenerate.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 754b76c..3e94348 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store src/UserAgents.php src/UserAgentsRSS.php composer.phar diff --git a/src/UserAgentsRSSGenerate.php b/src/UserAgentsRSSGenerate.php index 3881462..02d30c8 100644 --- a/src/UserAgentsRSSGenerate.php +++ b/src/UserAgentsRSSGenerate.php @@ -24,7 +24,6 @@ class UserAgentsRSS { public static function find(\$userAgent) { \$serviceFound = null; - //Search for current HTTP_USER_AGENT: foreach (self::\$db as \$service) { //Does the HTTP_USER_AGENT match this regexp: @@ -41,6 +40,20 @@ public static function find(\$userAgent) return \$serviceFound; } + public static function getName(\$slug) + { + \$name = null; + //Search for current HTTP_USER_AGENT: + foreach (self::\$db as \$service) { + if (\$slug === \$service['slug']) { + \$name = \$service['name']; + //We found it! + break 1; + } + } + return \$name; + } + EOT; print " static public \$db = ";