]> git.mxchange.org Git - friendica.git/commitdiff
Reduce cyclomatic complexity in GServer::detect()
authorArt4 <art4@wlabs.de>
Wed, 25 Dec 2024 18:33:04 +0000 (18:33 +0000)
committerArt4 <art4@wlabs.de>
Wed, 25 Dec 2024 18:33:04 +0000 (18:33 +0000)
src/Model/GServer.php

index a0c1be7bfcc9e6f9f36f0896be96d1fd11a36b68..4d7743f0dbc3dbbd81c8d0168c5145bd33ad5b6c 100644 (file)
@@ -815,6 +815,25 @@ class GServer
                }
 
                // Count the number of known contacts from this server
+               self::countNumberOfKnownContacts((int) $id, $serverdata);
+
+               if (in_array($serverdata['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
+                       self::discoverRelay($url);
+               }
+
+               if (!empty($systemactor)) {
+                       $contact = Contact::getByURL($systemactor, true, ['gsid', 'baseurl', 'id', 'network', 'url', 'name']);
+                       Logger::debug('Fetched system actor',  ['url' => $url, 'gsid' => $id, 'contact' => $contact]);
+               }
+
+               return $ret;
+       }
+
+       /**
+        * Count the number of known contacts from this server
+        */
+       private static function countNumberOfKnownContacts(int $id, array $serverdata): void
+       {
                if (!empty($id) && !in_array($serverdata['network'], [Protocol::PHANTOM, Protocol::FEED])) {
                        $apcontacts = DBA::count('apcontact', ['gsid' => $id]);
                        $contacts = DBA::count('contact', ['uid' => 0, 'gsid' => $id, 'failed' => false]);
@@ -840,17 +859,6 @@ class GServer
                                }
                        }
                }
-
-               if (in_array($serverdata['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
-                       self::discoverRelay($url);
-               }
-
-               if (!empty($systemactor)) {
-                       $contact = Contact::getByURL($systemactor, true, ['gsid', 'baseurl', 'id', 'network', 'url', 'name']);
-                       Logger::debug('Fetched system actor',  ['url' => $url, 'gsid' => $id, 'contact' => $contact]);
-               }
-
-               return $ret;
        }
 
        /**