Passed
Push — master ( 6d96b3...fbab9c )
by Roeland
20:00 queued 09:39
created
lib/private/App/AppStore/Fetcher/AppFetcher.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -39,117 +39,117 @@
 block discarded – undo
39 39
 
40 40
 class AppFetcher extends Fetcher {
41 41
 
42
-	/** @var CompareVersion */
43
-	private $compareVersion;
42
+    /** @var CompareVersion */
43
+    private $compareVersion;
44 44
 
45
-	/** @var bool */
46
-	private $ignoreMaxVersion;
45
+    /** @var bool */
46
+    private $ignoreMaxVersion;
47 47
 
48
-	/**
49
-	 * @param Factory $appDataFactory
50
-	 * @param IClientService $clientService
51
-	 * @param ITimeFactory $timeFactory
52
-	 * @param IConfig $config
53
-	 * @param CompareVersion $compareVersion
54
-	 * @param ILogger $logger
55
-	 */
56
-	public function __construct(Factory $appDataFactory,
57
-								IClientService $clientService,
58
-								ITimeFactory $timeFactory,
59
-								IConfig $config,
60
-								CompareVersion $compareVersion,
61
-								ILogger $logger) {
62
-		parent::__construct(
63
-			$appDataFactory,
64
-			$clientService,
65
-			$timeFactory,
66
-			$config,
67
-			$logger
68
-		);
48
+    /**
49
+     * @param Factory $appDataFactory
50
+     * @param IClientService $clientService
51
+     * @param ITimeFactory $timeFactory
52
+     * @param IConfig $config
53
+     * @param CompareVersion $compareVersion
54
+     * @param ILogger $logger
55
+     */
56
+    public function __construct(Factory $appDataFactory,
57
+                                IClientService $clientService,
58
+                                ITimeFactory $timeFactory,
59
+                                IConfig $config,
60
+                                CompareVersion $compareVersion,
61
+                                ILogger $logger) {
62
+        parent::__construct(
63
+            $appDataFactory,
64
+            $clientService,
65
+            $timeFactory,
66
+            $config,
67
+            $logger
68
+        );
69 69
 
70
-		$this->fileName = 'apps.json';
71
-		$this->compareVersion = $compareVersion;
72
-		$this->ignoreMaxVersion = true;
73
-	}
70
+        $this->fileName = 'apps.json';
71
+        $this->compareVersion = $compareVersion;
72
+        $this->ignoreMaxVersion = true;
73
+    }
74 74
 
75
-	/**
76
-	 * Only returns the latest compatible app release in the releases array
77
-	 *
78
-	 * @param string $ETag
79
-	 * @param string $content
80
-	 *
81
-	 * @return array
82
-	 */
83
-	protected function fetch($ETag, $content) {
84
-		/** @var mixed[] $response */
85
-		$response = parent::fetch($ETag, $content);
75
+    /**
76
+     * Only returns the latest compatible app release in the releases array
77
+     *
78
+     * @param string $ETag
79
+     * @param string $content
80
+     *
81
+     * @return array
82
+     */
83
+    protected function fetch($ETag, $content) {
84
+        /** @var mixed[] $response */
85
+        $response = parent::fetch($ETag, $content);
86 86
 
87
-		$allowPreReleases = $this->getChannel() === 'beta' || $this->getChannel() === 'daily';
88
-		$allowNightly = $this->getChannel() === 'daily';
87
+        $allowPreReleases = $this->getChannel() === 'beta' || $this->getChannel() === 'daily';
88
+        $allowNightly = $this->getChannel() === 'daily';
89 89
 
90
-		foreach($response['data'] as $dataKey => $app) {
91
-			$releases = [];
90
+        foreach($response['data'] as $dataKey => $app) {
91
+            $releases = [];
92 92
 
93
-			// Filter all compatible releases
94
-			foreach($app['releases'] as $release) {
95
-				// Exclude all nightly and pre-releases if required
96
-				if (($allowNightly || $release['isNightly'] === false)
97
-					&& ($allowPreReleases || strpos($release['version'], '-') === false)) {
98
-					// Exclude all versions not compatible with the current version
99
-					try {
100
-						$versionParser = new VersionParser();
101
-						$version = $versionParser->getVersion($release['rawPlatformVersionSpec']);
102
-						$ncVersion = $this->getVersion();
103
-						$min = $version->getMinimumVersion();
104
-						$max = $version->getMaximumVersion();
105
-						$minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>=');
106
-						$maxFulfilled = $max !== '' &&
107
-							$this->compareVersion->isCompatible($ncVersion, $max, '<=');
108
-						if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled)) {
109
-							$releases[] = $release;
110
-						}
111
-					} catch (\InvalidArgumentException $e) {
112
-						$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::WARN]);
113
-					}
114
-				}
115
-			}
93
+            // Filter all compatible releases
94
+            foreach($app['releases'] as $release) {
95
+                // Exclude all nightly and pre-releases if required
96
+                if (($allowNightly || $release['isNightly'] === false)
97
+                    && ($allowPreReleases || strpos($release['version'], '-') === false)) {
98
+                    // Exclude all versions not compatible with the current version
99
+                    try {
100
+                        $versionParser = new VersionParser();
101
+                        $version = $versionParser->getVersion($release['rawPlatformVersionSpec']);
102
+                        $ncVersion = $this->getVersion();
103
+                        $min = $version->getMinimumVersion();
104
+                        $max = $version->getMaximumVersion();
105
+                        $minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>=');
106
+                        $maxFulfilled = $max !== '' &&
107
+                            $this->compareVersion->isCompatible($ncVersion, $max, '<=');
108
+                        if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled)) {
109
+                            $releases[] = $release;
110
+                        }
111
+                    } catch (\InvalidArgumentException $e) {
112
+                        $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::WARN]);
113
+                    }
114
+                }
115
+            }
116 116
 
117
-			if (empty($releases)) {
118
-				// Remove apps that don't have a matching release
119
-				$response['data'][$dataKey] = [];
120
-				continue;
121
-			}
117
+            if (empty($releases)) {
118
+                // Remove apps that don't have a matching release
119
+                $response['data'][$dataKey] = [];
120
+                continue;
121
+            }
122 122
 
123
-			// Get the highest version
124
-			$versions = [];
125
-			foreach($releases as $release) {
126
-				$versions[] = $release['version'];
127
-			}
128
-			usort($versions, 'version_compare');
129
-			$versions = array_reverse($versions);
130
-			if(isset($versions[0])) {
131
-				$highestVersion = $versions[0];
132
-				foreach ($releases as $release) {
133
-					if ((string)$release['version'] === (string)$highestVersion) {
134
-						$response['data'][$dataKey]['releases'] = [$release];
135
-						break;
136
-					}
137
-				}
138
-			}
139
-		}
123
+            // Get the highest version
124
+            $versions = [];
125
+            foreach($releases as $release) {
126
+                $versions[] = $release['version'];
127
+            }
128
+            usort($versions, 'version_compare');
129
+            $versions = array_reverse($versions);
130
+            if(isset($versions[0])) {
131
+                $highestVersion = $versions[0];
132
+                foreach ($releases as $release) {
133
+                    if ((string)$release['version'] === (string)$highestVersion) {
134
+                        $response['data'][$dataKey]['releases'] = [$release];
135
+                        break;
136
+                    }
137
+                }
138
+            }
139
+        }
140 140
 
141
-		$response['data'] = array_values(array_filter($response['data']));
142
-		return $response;
143
-	}
141
+        $response['data'] = array_values(array_filter($response['data']));
142
+        return $response;
143
+    }
144 144
 
145
-	/**
146
-	 * @param string $version
147
-	 * @param string $fileName
148
-	 * @param bool $ignoreMaxVersion
149
-	 */
150
-	public function setVersion(string $version, string $fileName = 'apps.json', bool $ignoreMaxVersion = true) {
151
-		parent::setVersion($version);
152
-		$this->fileName = $fileName;
153
-		$this->ignoreMaxVersion = $ignoreMaxVersion;
154
-	}
145
+    /**
146
+     * @param string $version
147
+     * @param string $fileName
148
+     * @param bool $ignoreMaxVersion
149
+     */
150
+    public function setVersion(string $version, string $fileName = 'apps.json', bool $ignoreMaxVersion = true) {
151
+        parent::setVersion($version);
152
+        $this->fileName = $fileName;
153
+        $this->ignoreMaxVersion = $ignoreMaxVersion;
154
+    }
155 155
 }
Please login to merge, or discard this patch.