Skip to content

Commit 116c4a7

Browse files
authored
Updated to reduce overall complexity of function
1 parent 3285908 commit 116c4a7

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

app/code/Magento/Downloadable/Helper/Download.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -183,26 +183,23 @@ public function getFileSize()
183183
*
184184
* @return string
185185
*/
186-
public function getContentType()
186+
public function getContentType()
187187
{
188188
$this->_getHandle();
189-
if ($this->_linkType == self::LINK_TYPE_FILE) {
190-
if (function_exists(
191-
'mime_content_type'
192-
) && ($contentType = mime_content_type(
193-
$this->_workingDirectory->getAbsolutePath($this->_resourceFile)
194-
))
189+
if ($this->_linkType === self::LINK_TYPE_FILE) {
190+
if (function_exists('mime_content_type')
191+
&& ($contentType = mime_content_type(
192+
$this->_workingDirectory->getAbsolutePath($this->_resourceFile)
193+
))
195194
) {
196195
return $contentType;
197-
} else {
198-
return $this->_downloadableFile->getFileType($this->_resourceFile);
199-
}
200-
} elseif ($this->_linkType == self::LINK_TYPE_URL) {
201-
if (is_array($this->_handle->stat($this->_resourceFile)['type'])) {
202-
return end($this->_handle->stat($this->_resourceFile)['type']);
203-
} else {
204-
return $this->_handle->stat($this->_resourceFile)['type'];
205196
}
197+
return $this->_downloadableFile->getFileType($this->_resourceFile);
198+
}
199+
if ($this->_linkType === self::LINK_TYPE_URL) {
200+
return (is_array($this->_handle->stat($this->_resourceFile)['type'])
201+
? end($this->_handle->stat($this->_resourceFile)['type'])
202+
: $this->_handle->stat($this->_resourceFile)['type']);
206203
}
207204
return $this->_contentType;
208205
}

0 commit comments

Comments
 (0)