Skip to content

Commit 2bc47d2

Browse files
committed
refactor: common file URL function
1 parent c13e4eb commit 2bc47d2

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

includes/Core/Util/Common.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,14 @@ public static function fileUrl($file)
7777
$fileBasePath = str_replace('\\', '/', $upDir['basedir']);
7878

7979
if (\is_array($file)) {
80-
$Url = [];
81-
foreach ($file as $fileIndex => $fileUrl) {
82-
$Url[$fileIndex] = str_replace($fileBaseURL, $fileBasePath, $fileUrl);
83-
}
80+
$url = array_map(function ($filePath) use ($fileBasePath, $fileBaseURL) {
81+
return str_replace($fileBasePath, $fileBaseURL, $filePath);
82+
}, $file);
8483
} else {
85-
$Url = str_replace($fileBasePath, $fileBaseURL, $file);
84+
$url = str_replace($fileBasePath, $fileBaseURL, $file);
8685
}
8786

88-
return $Url;
87+
return $url;
8988
}
9089

9190
/**
@@ -151,9 +150,7 @@ public static function checkCondition($condition, $data)
151150
}
152151
}
153152

154-
return (bool) ($checker === \count($valueToCheck) && \count($valueToCheck) === \count($fieldValue))
155-
156-
;
153+
return (bool) ($checker === \count($valueToCheck) && \count($valueToCheck) === \count($fieldValue));
157154
}
158155

159156
return $fieldValue === $valueToCheck;
@@ -194,9 +191,7 @@ public static function checkCondition($condition, $data)
194191
}
195192
}
196193

197-
return (bool) ($checker > 0)
198-
199-
;
194+
return (bool) ($checker > 0);
200195
}
201196

202197
return stripos($fieldValue, $valueToCheck) !== false;
@@ -213,9 +208,7 @@ public static function checkCondition($condition, $data)
213208
}
214209
}
215210

216-
return (bool) ($checker >= \count($valueToCheck))
217-
218-
;
211+
return (bool) ($checker >= \count($valueToCheck));
219212
}
220213

221214
return stripos($fieldValue, $valueToCheck) !== false;
@@ -232,9 +225,7 @@ public static function checkCondition($condition, $data)
232225
}
233226
}
234227

235-
return (bool) ($checker === \count($valueToCheck))
236-
237-
;
228+
return (bool) ($checker === \count($valueToCheck));
238229
}
239230

240231
return stripos($fieldValue, $valueToCheck) === false;

0 commit comments

Comments
 (0)