Skip to content

Commit 5ecf410

Browse files
authored
Merged logic and reduced overall complexity of function
Note: if() constructions that return boolean values based on conditions, can be simplified to return the condition instead.
1 parent 116c4a7 commit 5ecf410

File tree

1 file changed

+3
-16
lines changed
  • lib/internal/Magento/Framework/Filesystem/Driver

1 file changed

+3
-16
lines changed

lib/internal/Magento/Framework/Filesystem/Driver/Http.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,18 @@ class Http extends File
2727
*
2828
* @param string $path
2929
* @return bool
30-
* @throws FileSystemException
3130
*/
3231
public function isExists($path)
3332
{
3433
$headers = array_change_key_case(get_headers($this->getScheme() . $path, 1), CASE_LOWER);
35-
3634
$status = $headers[0];
3735

38-
/* Handling 302 redirection */
39-
if (strpos($status, '302 Found') !== false && isset($headers[1])) {
40-
$status = $headers[1];
41-
}
42-
43-
/* Handling 301 redirection */
44-
if (strpos($status, '301 Moved Permanently') !== false && isset($headers[1])) {
36+
/* Handling 301 or 302 redirection */
37+
if (isset($headers[1]) && preg_match('/^30[12]/', $status)) {
4538
$status = $headers[1];
4639
}
4740

48-
if (strpos($status, '200 OK') === false) {
49-
$result = false;
50-
} else {
51-
$result = true;
52-
}
53-
54-
return $result;
41+
return !(strpos($status, '200 OK') === false);
5542
}
5643

5744
/**

0 commit comments

Comments
 (0)