Completed
Push — master ( 618175...407cc4 )
by
unknown
42:19
created
apps/settings/lib/SetupChecks/InternetConnectivity.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -19,62 +19,62 @@
 block discarded – undo
19 19
  * Checks if the server can connect to the internet using HTTPS and HTTP
20 20
  */
21 21
 class InternetConnectivity implements ISetupCheck {
22
-	public function __construct(
23
-		private IL10N $l10n,
24
-		private IConfig $config,
25
-		private IClientService $clientService,
26
-		private LoggerInterface $logger,
27
-	) {
28
-	}
22
+    public function __construct(
23
+        private IL10N $l10n,
24
+        private IConfig $config,
25
+        private IClientService $clientService,
26
+        private LoggerInterface $logger,
27
+    ) {
28
+    }
29 29
 
30
-	public function getCategory(): string {
31
-		return 'network';
32
-	}
30
+    public function getCategory(): string {
31
+        return 'network';
32
+    }
33 33
 
34
-	public function getName(): string {
35
-		return $this->l10n->t('Internet connectivity');
36
-	}
34
+    public function getName(): string {
35
+        return $this->l10n->t('Internet connectivity');
36
+    }
37 37
 
38
-	public function run(): SetupResult {
39
-		if ($this->config->getSystemValue('has_internet_connection', true) === false) {
40
-			return SetupResult::success($this->l10n->t('Internet connectivity is disabled in configuration file.'));
41
-		}
38
+    public function run(): SetupResult {
39
+        if ($this->config->getSystemValue('has_internet_connection', true) === false) {
40
+            return SetupResult::success($this->l10n->t('Internet connectivity is disabled in configuration file.'));
41
+        }
42 42
 
43
-		$siteArray = $this->config->getSystemValue('connectivity_check_domains', [
44
-			'https://connectivity.nextcloud.com', 'https://www.eff.org', 'https://edri.org'
45
-		]);
43
+        $siteArray = $this->config->getSystemValue('connectivity_check_domains', [
44
+            'https://connectivity.nextcloud.com', 'https://www.eff.org', 'https://edri.org'
45
+        ]);
46 46
 
47
-		foreach ($siteArray as $site) {
48
-			if ($this->isSiteReachable($site)) {
49
-				// successful as soon as one connection succeeds
50
-				return SetupResult::success();
51
-			}
52
-		}
53
-		return SetupResult::warning($this->l10n->t('This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.'));
54
-	}
47
+        foreach ($siteArray as $site) {
48
+            if ($this->isSiteReachable($site)) {
49
+                // successful as soon as one connection succeeds
50
+                return SetupResult::success();
51
+            }
52
+        }
53
+        return SetupResult::warning($this->l10n->t('This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.'));
54
+    }
55 55
 
56
-	/**
57
-	 * Checks if the Nextcloud server can connect to a specific URL
58
-	 * @param string $site site domain or full URL with http/https protocol
59
-	 * @return bool success/failure
60
-	 */
61
-	private function isSiteReachable(string $site): bool {
62
-		// if there is no protocol specified, test http:// first then, if necessary, https://
63
-		if (preg_match('/^https?:\/\//', $site) !== 1) {
64
-			$httpSite = 'http://' . $site . '/';
65
-			$httpsSite = 'https://' . $site . '/';
66
-			return $this->isSiteReachable($httpSite) || $this->isSiteReachable($httpsSite);
67
-		}
68
-		try {
69
-			$client = $this->clientService->newClient();
70
-			$client->head($site);
71
-		} catch (\Exception $e) {
72
-			$this->logger->error('Cannot connect to: ' . $site, [
73
-				'app' => 'internet_connection_check',
74
-				'exception' => $e,
75
-			]);
76
-			return false;
77
-		}
78
-		return true;
79
-	}
56
+    /**
57
+     * Checks if the Nextcloud server can connect to a specific URL
58
+     * @param string $site site domain or full URL with http/https protocol
59
+     * @return bool success/failure
60
+     */
61
+    private function isSiteReachable(string $site): bool {
62
+        // if there is no protocol specified, test http:// first then, if necessary, https://
63
+        if (preg_match('/^https?:\/\//', $site) !== 1) {
64
+            $httpSite = 'http://' . $site . '/';
65
+            $httpsSite = 'https://' . $site . '/';
66
+            return $this->isSiteReachable($httpSite) || $this->isSiteReachable($httpsSite);
67
+        }
68
+        try {
69
+            $client = $this->clientService->newClient();
70
+            $client->head($site);
71
+        } catch (\Exception $e) {
72
+            $this->logger->error('Cannot connect to: ' . $site, [
73
+                'app' => 'internet_connection_check',
74
+                'exception' => $e,
75
+            ]);
76
+            return false;
77
+        }
78
+        return true;
79
+    }
80 80
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,15 +61,15 @@
 block discarded – undo
61 61
 	private function isSiteReachable(string $site): bool {
62 62
 		// if there is no protocol specified, test http:// first then, if necessary, https://
63 63
 		if (preg_match('/^https?:\/\//', $site) !== 1) {
64
-			$httpSite = 'http://' . $site . '/';
65
-			$httpsSite = 'https://' . $site . '/';
64
+			$httpSite = 'http://'.$site.'/';
65
+			$httpsSite = 'https://'.$site.'/';
66 66
 			return $this->isSiteReachable($httpSite) || $this->isSiteReachable($httpsSite);
67 67
 		}
68 68
 		try {
69 69
 			$client = $this->clientService->newClient();
70 70
 			$client->head($site);
71 71
 		} catch (\Exception $e) {
72
-			$this->logger->error('Cannot connect to: ' . $site, [
72
+			$this->logger->error('Cannot connect to: '.$site, [
73 73
 				'app' => 'internet_connection_check',
74 74
 				'exception' => $e,
75 75
 			]);
Please login to merge, or discard this patch.