Passed
Push — master ( eb1927...20f197 )
by Julius
31:49 queued 12s
created
apps/theming/lib/ImageManager.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -46,274 +46,274 @@
 block discarded – undo
46 46
 
47 47
 class ImageManager {
48 48
 
49
-	/** @var IConfig */
50
-	private $config;
51
-	/** @var IAppData */
52
-	private $appData;
53
-	/** @var IURLGenerator */
54
-	private $urlGenerator;
55
-	/** @var array */
56
-	private $supportedImageKeys = ['background', 'logo', 'logoheader', 'favicon'];
57
-	/** @var ICacheFactory */
58
-	private $cacheFactory;
59
-	/** @var ILogger */
60
-	private $logger;
61
-	/** @var ITempManager */
62
-	private $tempManager;
49
+    /** @var IConfig */
50
+    private $config;
51
+    /** @var IAppData */
52
+    private $appData;
53
+    /** @var IURLGenerator */
54
+    private $urlGenerator;
55
+    /** @var array */
56
+    private $supportedImageKeys = ['background', 'logo', 'logoheader', 'favicon'];
57
+    /** @var ICacheFactory */
58
+    private $cacheFactory;
59
+    /** @var ILogger */
60
+    private $logger;
61
+    /** @var ITempManager */
62
+    private $tempManager;
63 63
 
64
-	public function __construct(IConfig $config,
65
-								IAppData $appData,
66
-								IURLGenerator $urlGenerator,
67
-								ICacheFactory $cacheFactory,
68
-								ILogger $logger,
69
-								ITempManager $tempManager
70
-	) {
71
-		$this->config = $config;
72
-		$this->appData = $appData;
73
-		$this->urlGenerator = $urlGenerator;
74
-		$this->cacheFactory = $cacheFactory;
75
-		$this->logger = $logger;
76
-		$this->tempManager = $tempManager;
77
-	}
64
+    public function __construct(IConfig $config,
65
+                                IAppData $appData,
66
+                                IURLGenerator $urlGenerator,
67
+                                ICacheFactory $cacheFactory,
68
+                                ILogger $logger,
69
+                                ITempManager $tempManager
70
+    ) {
71
+        $this->config = $config;
72
+        $this->appData = $appData;
73
+        $this->urlGenerator = $urlGenerator;
74
+        $this->cacheFactory = $cacheFactory;
75
+        $this->logger = $logger;
76
+        $this->tempManager = $tempManager;
77
+    }
78 78
 
79
-	public function getImageUrl(string $key, bool $useSvg = true): string {
80
-		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
81
-		if ($this->hasImage($key)) {
82
-			return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter;
83
-		}
79
+    public function getImageUrl(string $key, bool $useSvg = true): string {
80
+        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
81
+        if ($this->hasImage($key)) {
82
+            return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter;
83
+        }
84 84
 
85
-		switch ($key) {
86
-			case 'logo':
87
-			case 'logoheader':
88
-			case 'favicon':
89
-				return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter;
90
-			case 'background':
91
-				return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter;
92
-		}
93
-		return '';
94
-	}
85
+        switch ($key) {
86
+            case 'logo':
87
+            case 'logoheader':
88
+            case 'favicon':
89
+                return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter;
90
+            case 'background':
91
+                return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter;
92
+        }
93
+        return '';
94
+    }
95 95
 
96
-	public function getImageUrlAbsolute(string $key, bool $useSvg = true): string {
97
-		return $this->urlGenerator->getAbsoluteURL($this->getImageUrl($key, $useSvg));
98
-	}
96
+    public function getImageUrlAbsolute(string $key, bool $useSvg = true): string {
97
+        return $this->urlGenerator->getAbsoluteURL($this->getImageUrl($key, $useSvg));
98
+    }
99 99
 
100
-	/**
101
-	 * @param string $key
102
-	 * @param bool $useSvg
103
-	 * @return ISimpleFile
104
-	 * @throws NotFoundException
105
-	 * @throws NotPermittedException
106
-	 */
107
-	public function getImage(string $key, bool $useSvg = true): ISimpleFile {
108
-		$logo = $this->config->getAppValue('theming', $key . 'Mime', '');
109
-		$folder = $this->appData->getFolder('images');
110
-		if ($logo === '' || !$folder->fileExists($key)) {
111
-			throw new NotFoundException();
112
-		}
113
-		if (!$useSvg && $this->shouldReplaceIcons()) {
114
-			if (!$folder->fileExists($key . '.png')) {
115
-				try {
116
-					$finalIconFile = new \Imagick();
117
-					$finalIconFile->setBackgroundColor('none');
118
-					$finalIconFile->readImageBlob($folder->getFile($key)->getContent());
119
-					$finalIconFile->setImageFormat('png32');
120
-					$pngFile = $folder->newFile($key . '.png');
121
-					$pngFile->putContent($finalIconFile->getImageBlob());
122
-					return $pngFile;
123
-				} catch (\ImagickException $e) {
124
-					$this->logger->info('The image was requested to be no SVG file, but converting it to PNG failed: ' . $e->getMessage());
125
-				}
126
-			} else {
127
-				return $folder->getFile($key . '.png');
128
-			}
129
-		}
130
-		return $folder->getFile($key);
131
-	}
100
+    /**
101
+     * @param string $key
102
+     * @param bool $useSvg
103
+     * @return ISimpleFile
104
+     * @throws NotFoundException
105
+     * @throws NotPermittedException
106
+     */
107
+    public function getImage(string $key, bool $useSvg = true): ISimpleFile {
108
+        $logo = $this->config->getAppValue('theming', $key . 'Mime', '');
109
+        $folder = $this->appData->getFolder('images');
110
+        if ($logo === '' || !$folder->fileExists($key)) {
111
+            throw new NotFoundException();
112
+        }
113
+        if (!$useSvg && $this->shouldReplaceIcons()) {
114
+            if (!$folder->fileExists($key . '.png')) {
115
+                try {
116
+                    $finalIconFile = new \Imagick();
117
+                    $finalIconFile->setBackgroundColor('none');
118
+                    $finalIconFile->readImageBlob($folder->getFile($key)->getContent());
119
+                    $finalIconFile->setImageFormat('png32');
120
+                    $pngFile = $folder->newFile($key . '.png');
121
+                    $pngFile->putContent($finalIconFile->getImageBlob());
122
+                    return $pngFile;
123
+                } catch (\ImagickException $e) {
124
+                    $this->logger->info('The image was requested to be no SVG file, but converting it to PNG failed: ' . $e->getMessage());
125
+                }
126
+            } else {
127
+                return $folder->getFile($key . '.png');
128
+            }
129
+        }
130
+        return $folder->getFile($key);
131
+    }
132 132
 
133
-	public function hasImage(string $key): bool {
134
-		$mimeSetting = $this->config->getAppValue('theming', $key . 'Mime', '');
135
-		return $mimeSetting !== '';
136
-	}
133
+    public function hasImage(string $key): bool {
134
+        $mimeSetting = $this->config->getAppValue('theming', $key . 'Mime', '');
135
+        return $mimeSetting !== '';
136
+    }
137 137
 
138
-	/**
139
-	 * @return array<string, array{mime: string, url: string}>
140
-	 */
141
-	public function getCustomImages(): array {
142
-		$images = [];
143
-		foreach ($this->supportedImageKeys as $key) {
144
-			$images[$key] = [
145
-				'mime' => $this->config->getAppValue('theming', $key . 'Mime', ''),
146
-				'url' => $this->getImageUrl($key),
147
-			];
148
-		}
149
-		return $images;
150
-	}
138
+    /**
139
+     * @return array<string, array{mime: string, url: string}>
140
+     */
141
+    public function getCustomImages(): array {
142
+        $images = [];
143
+        foreach ($this->supportedImageKeys as $key) {
144
+            $images[$key] = [
145
+                'mime' => $this->config->getAppValue('theming', $key . 'Mime', ''),
146
+                'url' => $this->getImageUrl($key),
147
+            ];
148
+        }
149
+        return $images;
150
+    }
151 151
 
152
-	/**
153
-	 * Get folder for current theming files
154
-	 *
155
-	 * @return ISimpleFolder
156
-	 * @throws NotPermittedException
157
-	 */
158
-	public function getCacheFolder(): ISimpleFolder {
159
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
160
-		try {
161
-			$folder = $this->appData->getFolder($cacheBusterValue);
162
-		} catch (NotFoundException $e) {
163
-			$folder = $this->appData->newFolder($cacheBusterValue);
164
-			$this->cleanup();
165
-		}
166
-		return $folder;
167
-	}
152
+    /**
153
+     * Get folder for current theming files
154
+     *
155
+     * @return ISimpleFolder
156
+     * @throws NotPermittedException
157
+     */
158
+    public function getCacheFolder(): ISimpleFolder {
159
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
160
+        try {
161
+            $folder = $this->appData->getFolder($cacheBusterValue);
162
+        } catch (NotFoundException $e) {
163
+            $folder = $this->appData->newFolder($cacheBusterValue);
164
+            $this->cleanup();
165
+        }
166
+        return $folder;
167
+    }
168 168
 
169
-	/**
170
-	 * Get a file from AppData
171
-	 *
172
-	 * @param string $filename
173
-	 * @throws NotFoundException
174
-	 * @return \OCP\Files\SimpleFS\ISimpleFile
175
-	 * @throws NotPermittedException
176
-	 */
177
-	public function getCachedImage(string $filename): ISimpleFile {
178
-		$currentFolder = $this->getCacheFolder();
179
-		return $currentFolder->getFile($filename);
180
-	}
169
+    /**
170
+     * Get a file from AppData
171
+     *
172
+     * @param string $filename
173
+     * @throws NotFoundException
174
+     * @return \OCP\Files\SimpleFS\ISimpleFile
175
+     * @throws NotPermittedException
176
+     */
177
+    public function getCachedImage(string $filename): ISimpleFile {
178
+        $currentFolder = $this->getCacheFolder();
179
+        return $currentFolder->getFile($filename);
180
+    }
181 181
 
182
-	/**
183
-	 * Store a file for theming in AppData
184
-	 *
185
-	 * @param string $filename
186
-	 * @param string $data
187
-	 * @return \OCP\Files\SimpleFS\ISimpleFile
188
-	 * @throws NotFoundException
189
-	 * @throws NotPermittedException
190
-	 */
191
-	public function setCachedImage(string $filename, string $data): ISimpleFile {
192
-		$currentFolder = $this->getCacheFolder();
193
-		if ($currentFolder->fileExists($filename)) {
194
-			$file = $currentFolder->getFile($filename);
195
-		} else {
196
-			$file = $currentFolder->newFile($filename);
197
-		}
198
-		$file->putContent($data);
199
-		return $file;
200
-	}
182
+    /**
183
+     * Store a file for theming in AppData
184
+     *
185
+     * @param string $filename
186
+     * @param string $data
187
+     * @return \OCP\Files\SimpleFS\ISimpleFile
188
+     * @throws NotFoundException
189
+     * @throws NotPermittedException
190
+     */
191
+    public function setCachedImage(string $filename, string $data): ISimpleFile {
192
+        $currentFolder = $this->getCacheFolder();
193
+        if ($currentFolder->fileExists($filename)) {
194
+            $file = $currentFolder->getFile($filename);
195
+        } else {
196
+            $file = $currentFolder->newFile($filename);
197
+        }
198
+        $file->putContent($data);
199
+        return $file;
200
+    }
201 201
 
202
-	public function delete(string $key): void {
203
-		/* ignore exceptions, since we don't want to fail hard if something goes wrong during cleanup */
204
-		try {
205
-			$file = $this->appData->getFolder('images')->getFile($key);
206
-			$file->delete();
207
-		} catch (NotFoundException $e) {
208
-		} catch (NotPermittedException $e) {
209
-		}
210
-		try {
211
-			$file = $this->appData->getFolder('images')->getFile($key . '.png');
212
-			$file->delete();
213
-		} catch (NotFoundException $e) {
214
-		} catch (NotPermittedException $e) {
215
-		}
216
-	}
202
+    public function delete(string $key): void {
203
+        /* ignore exceptions, since we don't want to fail hard if something goes wrong during cleanup */
204
+        try {
205
+            $file = $this->appData->getFolder('images')->getFile($key);
206
+            $file->delete();
207
+        } catch (NotFoundException $e) {
208
+        } catch (NotPermittedException $e) {
209
+        }
210
+        try {
211
+            $file = $this->appData->getFolder('images')->getFile($key . '.png');
212
+            $file->delete();
213
+        } catch (NotFoundException $e) {
214
+        } catch (NotPermittedException $e) {
215
+        }
216
+    }
217 217
 
218
-	public function updateImage(string $key, string $tmpFile): string {
219
-		$this->delete($key);
218
+    public function updateImage(string $key, string $tmpFile): string {
219
+        $this->delete($key);
220 220
 
221
-		try {
222
-			$folder = $this->appData->getFolder('images');
223
-		} catch (NotFoundException $e) {
224
-			$folder = $this->appData->newFolder('images');
225
-		}
221
+        try {
222
+            $folder = $this->appData->getFolder('images');
223
+        } catch (NotFoundException $e) {
224
+            $folder = $this->appData->newFolder('images');
225
+        }
226 226
 
227
-		$target = $folder->newFile($key);
228
-		$supportedFormats = $this->getSupportedUploadImageFormats($key);
229
-		$detectedMimeType = mime_content_type($tmpFile);
230
-		if (!in_array($detectedMimeType, $supportedFormats, true)) {
231
-			throw new \Exception('Unsupported image type');
232
-		}
227
+        $target = $folder->newFile($key);
228
+        $supportedFormats = $this->getSupportedUploadImageFormats($key);
229
+        $detectedMimeType = mime_content_type($tmpFile);
230
+        if (!in_array($detectedMimeType, $supportedFormats, true)) {
231
+            throw new \Exception('Unsupported image type');
232
+        }
233 233
 
234
-		if ($key === 'background' && strpos($detectedMimeType, 'image/svg') === false && strpos($detectedMimeType, 'image/gif') === false) {
235
-			// Optimize the image since some people may upload images that will be
236
-			// either to big or are not progressive rendering.
237
-			$newImage = @imagecreatefromstring(file_get_contents($tmpFile));
234
+        if ($key === 'background' && strpos($detectedMimeType, 'image/svg') === false && strpos($detectedMimeType, 'image/gif') === false) {
235
+            // Optimize the image since some people may upload images that will be
236
+            // either to big or are not progressive rendering.
237
+            $newImage = @imagecreatefromstring(file_get_contents($tmpFile));
238 238
 
239
-			// Preserve transparency
240
-			imagesavealpha($newImage, true);
241
-			imagealphablending($newImage, true);
239
+            // Preserve transparency
240
+            imagesavealpha($newImage, true);
241
+            imagealphablending($newImage, true);
242 242
 
243
-			$tmpFile = $this->tempManager->getTemporaryFile();
244
-			$newWidth = (int)(imagesx($newImage) < 4096 ? imagesx($newImage) : 4096);
245
-			$newHeight = (int)(imagesy($newImage) / (imagesx($newImage) / $newWidth));
246
-			$outputImage = imagescale($newImage, $newWidth, $newHeight);
243
+            $tmpFile = $this->tempManager->getTemporaryFile();
244
+            $newWidth = (int)(imagesx($newImage) < 4096 ? imagesx($newImage) : 4096);
245
+            $newHeight = (int)(imagesy($newImage) / (imagesx($newImage) / $newWidth));
246
+            $outputImage = imagescale($newImage, $newWidth, $newHeight);
247 247
 
248
-			imageinterlace($outputImage, 1);
249
-			imagepng($outputImage, $tmpFile, 8);
250
-			imagedestroy($outputImage);
248
+            imageinterlace($outputImage, 1);
249
+            imagepng($outputImage, $tmpFile, 8);
250
+            imagedestroy($outputImage);
251 251
 
252
-			$target->putContent(file_get_contents($tmpFile));
253
-		} else {
254
-			$target->putContent(file_get_contents($tmpFile));
255
-		}
252
+            $target->putContent(file_get_contents($tmpFile));
253
+        } else {
254
+            $target->putContent(file_get_contents($tmpFile));
255
+        }
256 256
 
257
-		return $detectedMimeType;
258
-	}
257
+        return $detectedMimeType;
258
+    }
259 259
 
260
-	/**
261
-	 * Returns a list of supported mime types for image uploads.
262
-	 * "favicon" images are only allowed to be SVG when imagemagick with SVG support is available.
263
-	 *
264
-	 * @param string $key The image key, e.g. "favicon"
265
-	 * @return string[]
266
-	 */
267
-	private function getSupportedUploadImageFormats(string $key): array {
268
-		$supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'];
260
+    /**
261
+     * Returns a list of supported mime types for image uploads.
262
+     * "favicon" images are only allowed to be SVG when imagemagick with SVG support is available.
263
+     *
264
+     * @param string $key The image key, e.g. "favicon"
265
+     * @return string[]
266
+     */
267
+    private function getSupportedUploadImageFormats(string $key): array {
268
+        $supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'];
269 269
 
270
-		if ($key !== 'favicon' || $this->shouldReplaceIcons() === true) {
271
-			$supportedFormats[] = 'image/svg+xml';
272
-			$supportedFormats[] = 'image/svg';
273
-		}
270
+        if ($key !== 'favicon' || $this->shouldReplaceIcons() === true) {
271
+            $supportedFormats[] = 'image/svg+xml';
272
+            $supportedFormats[] = 'image/svg';
273
+        }
274 274
 
275
-		if ($key === 'favicon') {
276
-			$supportedFormats[] = 'image/x-icon';
277
-			$supportedFormats[] = 'image/vnd.microsoft.icon';
278
-		}
275
+        if ($key === 'favicon') {
276
+            $supportedFormats[] = 'image/x-icon';
277
+            $supportedFormats[] = 'image/vnd.microsoft.icon';
278
+        }
279 279
 
280
-		return $supportedFormats;
281
-	}
280
+        return $supportedFormats;
281
+    }
282 282
 
283
-	/**
284
-	 * remove cached files that are not required any longer
285
-	 *
286
-	 * @throws NotPermittedException
287
-	 * @throws NotFoundException
288
-	 */
289
-	public function cleanup() {
290
-		$currentFolder = $this->getCacheFolder();
291
-		$folders = $this->appData->getDirectoryListing();
292
-		foreach ($folders as $folder) {
293
-			if ($folder->getName() !== 'images' && $folder->getName() !== $currentFolder->getName()) {
294
-				$folder->delete();
295
-			}
296
-		}
297
-	}
283
+    /**
284
+     * remove cached files that are not required any longer
285
+     *
286
+     * @throws NotPermittedException
287
+     * @throws NotFoundException
288
+     */
289
+    public function cleanup() {
290
+        $currentFolder = $this->getCacheFolder();
291
+        $folders = $this->appData->getDirectoryListing();
292
+        foreach ($folders as $folder) {
293
+            if ($folder->getName() !== 'images' && $folder->getName() !== $currentFolder->getName()) {
294
+                $folder->delete();
295
+            }
296
+        }
297
+    }
298 298
 
299
-	/**
300
-	 * Check if Imagemagick is enabled and if SVG is supported
301
-	 * otherwise we can't render custom icons
302
-	 *
303
-	 * @return bool
304
-	 */
305
-	public function shouldReplaceIcons() {
306
-		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
307
-		if ($value = $cache->get('shouldReplaceIcons')) {
308
-			return (bool)$value;
309
-		}
310
-		$value = false;
311
-		if (extension_loaded('imagick')) {
312
-			if (count(\Imagick::queryFormats('SVG')) >= 1) {
313
-				$value = true;
314
-			}
315
-		}
316
-		$cache->set('shouldReplaceIcons', $value);
317
-		return $value;
318
-	}
299
+    /**
300
+     * Check if Imagemagick is enabled and if SVG is supported
301
+     * otherwise we can't render custom icons
302
+     *
303
+     * @return bool
304
+     */
305
+    public function shouldReplaceIcons() {
306
+        $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
307
+        if ($value = $cache->get('shouldReplaceIcons')) {
308
+            return (bool)$value;
309
+        }
310
+        $value = false;
311
+        if (extension_loaded('imagick')) {
312
+            if (count(\Imagick::queryFormats('SVG')) >= 1) {
313
+                $value = true;
314
+            }
315
+        }
316
+        $cache->set('shouldReplaceIcons', $value);
317
+        return $value;
318
+    }
319 319
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
 	public function getImageUrl(string $key, bool $useSvg = true): string {
80 80
 		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
81 81
 		if ($this->hasImage($key)) {
82
-			return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter;
82
+			return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => $key]).'?v='.$cacheBusterCounter;
83 83
 		}
84 84
 
85 85
 		switch ($key) {
86 86
 			case 'logo':
87 87
 			case 'logoheader':
88 88
 			case 'favicon':
89
-				return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter;
89
+				return $this->urlGenerator->imagePath('core', 'logo/logo.png').'?v='.$cacheBusterCounter;
90 90
 			case 'background':
91
-				return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter;
91
+				return $this->urlGenerator->imagePath('core', 'background.png').'?v='.$cacheBusterCounter;
92 92
 		}
93 93
 		return '';
94 94
 	}
@@ -105,33 +105,33 @@  discard block
 block discarded – undo
105 105
 	 * @throws NotPermittedException
106 106
 	 */
107 107
 	public function getImage(string $key, bool $useSvg = true): ISimpleFile {
108
-		$logo = $this->config->getAppValue('theming', $key . 'Mime', '');
108
+		$logo = $this->config->getAppValue('theming', $key.'Mime', '');
109 109
 		$folder = $this->appData->getFolder('images');
110 110
 		if ($logo === '' || !$folder->fileExists($key)) {
111 111
 			throw new NotFoundException();
112 112
 		}
113 113
 		if (!$useSvg && $this->shouldReplaceIcons()) {
114
-			if (!$folder->fileExists($key . '.png')) {
114
+			if (!$folder->fileExists($key.'.png')) {
115 115
 				try {
116 116
 					$finalIconFile = new \Imagick();
117 117
 					$finalIconFile->setBackgroundColor('none');
118 118
 					$finalIconFile->readImageBlob($folder->getFile($key)->getContent());
119 119
 					$finalIconFile->setImageFormat('png32');
120
-					$pngFile = $folder->newFile($key . '.png');
120
+					$pngFile = $folder->newFile($key.'.png');
121 121
 					$pngFile->putContent($finalIconFile->getImageBlob());
122 122
 					return $pngFile;
123 123
 				} catch (\ImagickException $e) {
124
-					$this->logger->info('The image was requested to be no SVG file, but converting it to PNG failed: ' . $e->getMessage());
124
+					$this->logger->info('The image was requested to be no SVG file, but converting it to PNG failed: '.$e->getMessage());
125 125
 				}
126 126
 			} else {
127
-				return $folder->getFile($key . '.png');
127
+				return $folder->getFile($key.'.png');
128 128
 			}
129 129
 		}
130 130
 		return $folder->getFile($key);
131 131
 	}
132 132
 
133 133
 	public function hasImage(string $key): bool {
134
-		$mimeSetting = $this->config->getAppValue('theming', $key . 'Mime', '');
134
+		$mimeSetting = $this->config->getAppValue('theming', $key.'Mime', '');
135 135
 		return $mimeSetting !== '';
136 136
 	}
137 137
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		$images = [];
143 143
 		foreach ($this->supportedImageKeys as $key) {
144 144
 			$images[$key] = [
145
-				'mime' => $this->config->getAppValue('theming', $key . 'Mime', ''),
145
+				'mime' => $this->config->getAppValue('theming', $key.'Mime', ''),
146 146
 				'url' => $this->getImageUrl($key),
147 147
 			];
148 148
 		}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		} catch (NotPermittedException $e) {
209 209
 		}
210 210
 		try {
211
-			$file = $this->appData->getFolder('images')->getFile($key . '.png');
211
+			$file = $this->appData->getFolder('images')->getFile($key.'.png');
212 212
 			$file->delete();
213 213
 		} catch (NotFoundException $e) {
214 214
 		} catch (NotPermittedException $e) {
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 			imagealphablending($newImage, true);
242 242
 
243 243
 			$tmpFile = $this->tempManager->getTemporaryFile();
244
-			$newWidth = (int)(imagesx($newImage) < 4096 ? imagesx($newImage) : 4096);
245
-			$newHeight = (int)(imagesy($newImage) / (imagesx($newImage) / $newWidth));
244
+			$newWidth = (int) (imagesx($newImage) < 4096 ? imagesx($newImage) : 4096);
245
+			$newHeight = (int) (imagesy($newImage) / (imagesx($newImage) / $newWidth));
246 246
 			$outputImage = imagescale($newImage, $newWidth, $newHeight);
247 247
 
248 248
 			imageinterlace($outputImage, 1);
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	 * @return bool
304 304
 	 */
305 305
 	public function shouldReplaceIcons() {
306
-		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
306
+		$cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl());
307 307
 		if ($value = $cache->get('shouldReplaceIcons')) {
308
-			return (bool)$value;
308
+			return (bool) $value;
309 309
 		}
310 310
 		$value = false;
311 311
 		if (extension_loaded('imagick')) {
Please login to merge, or discard this patch.