Sorry, we don't support your browser.  Install a modern browser
This post is closed.

niceSize() for files objects#210

S

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).

3 years ago

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.

3 years ago
1
S

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!

3 years ago
Changed the status to
In progress
3 years ago
Changed the status to
In upcoming releases
3 years ago
Changed the status to
Completed
2 years ago