Skip to content

Commit

Permalink
Updated to reduce overall complexity of function
Browse files Browse the repository at this point in the history
  • Loading branch information
df2k2 authored Dec 31, 2018
1 parent 3285908 commit 116c4a7
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions app/code/Magento/Downloadable/Helper/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,26 +183,23 @@ public function getFileSize()
*
* @return string
*/
public function getContentType()
public function getContentType()
{
$this->_getHandle();
if ($this->_linkType == self::LINK_TYPE_FILE) {
if (function_exists(
'mime_content_type'
) && ($contentType = mime_content_type(
$this->_workingDirectory->getAbsolutePath($this->_resourceFile)
))
if ($this->_linkType === self::LINK_TYPE_FILE) {
if (function_exists('mime_content_type')
&& ($contentType = mime_content_type(
$this->_workingDirectory->getAbsolutePath($this->_resourceFile)
))
) {
return $contentType;
} else {
return $this->_downloadableFile->getFileType($this->_resourceFile);
}
} elseif ($this->_linkType == self::LINK_TYPE_URL) {
if (is_array($this->_handle->stat($this->_resourceFile)['type'])) {
return end($this->_handle->stat($this->_resourceFile)['type']);
} else {
return $this->_handle->stat($this->_resourceFile)['type'];
}
return $this->_downloadableFile->getFileType($this->_resourceFile);
}
if ($this->_linkType === self::LINK_TYPE_URL) {
return (is_array($this->_handle->stat($this->_resourceFile)['type'])
? end($this->_handle->stat($this->_resourceFile)['type'])
: $this->_handle->stat($this->_resourceFile)['type']);
}
return $this->_contentType;
}
Expand Down

0 comments on commit 116c4a7

Please sign in to comment.