Skip to content

Commit 393fec6

Browse files
committed
Add error handling in mime type detection
1 parent 5f6a488 commit 393fec6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ImageData/LogoImageData.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,14 @@ public function createDataUri(): string
113113
private static function detectMimeTypeFromUrl(string $url): string
114114
{
115115
$headers = get_headers($url, true);
116+
117+
if (!is_array($headers)) {
118+
throw new \Exception(sprintf('Could not retrieve headers to determine content type for logo URL "%s"', $url));
119+
}
120+
116121
$headers = array_combine(array_map('strtolower', array_keys($headers)), $headers);
117122

118-
if (!is_array($headers) || !isset($headers['content-type'])) {
123+
if (!isset($headers['content-type'])) {
119124
throw new \Exception(sprintf('Content type could not be determined for logo URL "%s"', $url));
120125
}
121126

0 commit comments

Comments
 (0)