Skip to content

Commit 9c5af0b

Browse files
committed
Improve code readability & backwards compatability
1 parent 8361da1 commit 9c5af0b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Api/ProductMediaFileApi.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,20 @@ protected function extractCodeFromCreationResponse(ResponseInterface $response)
132132
{
133133
$headers = $response->getHeaders();
134134

135-
$location = isset($headers['Location'][0]) ? $headers['Location'][0] : $headers['location'][0] ?? null;
135+
if (isset($headers['Location'][0])) {
136+
$locationHeader = $headers['Location'][0];
137+
}
138+
139+
if (isset($headers['location'][0])) {
140+
$locationHeader = $headers['location'][0];
141+
}
136142

137-
if (is_null($location)) {
143+
if (!isset($locationHeader)) {
138144
throw new RuntimeException('The response does not contain the URI of the created media-file.');
139145
}
140146

141147
$matches = [];
142-
if (1 !== preg_match(static::MEDIA_FILE_URI_CODE_REGEX, $location, $matches)) {
148+
if (1 !== preg_match(static::MEDIA_FILE_URI_CODE_REGEX, $locationHeader, $matches)) {
143149
throw new RuntimeException('Unable to find the code in the URI of the created media-file.');
144150
}
145151

0 commit comments

Comments
 (0)