Skip to content

Commit

Permalink
Merged logic and reduced overall complexity of function
Browse files Browse the repository at this point in the history
Note: if() constructions that return boolean values based on conditions, can be simplified to return the condition instead.
  • Loading branch information
df2k2 authored and Amol Chaudhari committed Feb 15, 2019
1 parent 7058adb commit dac6687
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions lib/internal/Magento/Framework/Filesystem/Driver/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,18 @@ class Http extends File
*
* @param string $path
* @return bool
* @throws FileSystemException
*/
public function isExists($path)
{
$headers = array_change_key_case(get_headers($this->getScheme() . $path, 1), CASE_LOWER);

$status = $headers[0];

/* Handling 302 redirection */
if (strpos($status, '302 Found') !== false && isset($headers[1])) {
$status = $headers[1];
}

/* Handling 301 redirection */
if (strpos($status, '301 Moved Permanently') !== false && isset($headers[1])) {
/* Handling 301 or 302 redirection */
if (isset($headers[1]) && preg_match('/^30[12]/', $status)) {
$status = $headers[1];
}

if (strpos($status, '200 OK') === false) {
$result = false;
} else {
$result = true;
}

return $result;
return !(strpos($status, '200 OK') === false);
}

/**
Expand Down

0 comments on commit dac6687

Please sign in to comment.