Upgrade to 3.6.2
This commit is contained in:
@@ -482,11 +482,14 @@ class Dir
|
||||
* Returns a nicely formatted size of all the contents of the folder
|
||||
*
|
||||
* @param string $dir The path of the directory
|
||||
* @param string|null|false $locale Locale for number formatting,
|
||||
* `null` for the current locale,
|
||||
* `false` to disable number formatting
|
||||
* @return mixed
|
||||
*/
|
||||
public static function niceSize(string $dir)
|
||||
public static function niceSize(string $dir, $locale = null)
|
||||
{
|
||||
return F::niceSize(static::size($dir));
|
||||
return F::niceSize(static::size($dir), $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -513,9 +516,7 @@ class Dir
|
||||
|
||||
// add absolute paths
|
||||
if ($absolute === true) {
|
||||
$result = array_map(function ($item) use ($dir) {
|
||||
return $dir . '/' . $item;
|
||||
}, $result);
|
||||
$result = array_map(fn ($item) => $dir . '/' . $item, $result);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@@ -756,9 +756,11 @@ class F
|
||||
public static function size($file): int
|
||||
{
|
||||
if (is_array($file) === true) {
|
||||
return array_reduce($file, function ($total, $file) {
|
||||
return $total + F::size($file);
|
||||
}, 0);
|
||||
return array_reduce(
|
||||
$file,
|
||||
fn ($total, $file) => $total + F::size($file),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -306,9 +306,11 @@ class File
|
||||
|
||||
// determine if any pattern matches the MIME type;
|
||||
// once any pattern matches, `$carry` is `true` and the rest is skipped
|
||||
$matches = array_reduce($rules['mime'], function ($carry, $pattern) use ($mime) {
|
||||
return $carry || Mime::matches($mime, $pattern);
|
||||
}, false);
|
||||
$matches = array_reduce(
|
||||
$rules['mime'],
|
||||
fn ($carry, $pattern) => $carry || Mime::matches($mime, $pattern),
|
||||
false
|
||||
);
|
||||
|
||||
if ($matches !== true) {
|
||||
throw new Exception([
|
||||
@@ -416,11 +418,14 @@ class File
|
||||
* Returns the file size in a
|
||||
* human-readable format
|
||||
*
|
||||
* @param string|null|false $locale Locale for number formatting,
|
||||
* `null` for the current locale,
|
||||
* `false` to disable number formatting
|
||||
* @return string
|
||||
*/
|
||||
public function niceSize(): string
|
||||
public function niceSize($locale = null): string
|
||||
{
|
||||
return F::niceSize($this->root);
|
||||
return F::niceSize($this->root, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user