I’m currently using this inside a plugin file:
'filesMethods' => [
'niceSize' => function ()
{
$size = 0;
foreach ($this as $file) {
$size = $size + F::size($file->root());
}
return F::niceSize($size);
},
],
.. but I’m wondering why that’s not part of the core - giving out size / niceSize of a files collection / object. I’d like to propose it being part of class F (with helper method as usual for $files).
As a first step, F::size()
and F::niceSize()
could accept an array of file paths next to the string
of a single file path and the int
for a pre-calculated size.
In the next step we could indeed integrate both of these into the Files
class.
I’ll see if I find the time to provide a PR, which should be the easiest way to get this done. I’m glad you are all for it!