Skip to content

Commit 9a3aacb

Browse files
committed
reorder enum fields, add user guide information
1 parent 5bb2170 commit 9a3aacb

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

system/Files/FileSizeUnit.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313

1414
namespace CodeIgniter\Files;
1515

16-
use InvalidArgumentException;
16+
use CodeIgniter\Exceptions\InvalidArgumentException;
1717

1818
enum FileSizeUnit: int
1919
{
20+
case B = 0;
21+
case KB = 1;
22+
case MB = 2;
23+
case GB = 3;
24+
case TB = 4;
25+
2026
/**
2127
* Allows the creation of a FileSizeUnit from Strings like "kb" or "mb"
2228
*
@@ -33,10 +39,4 @@ public static function fromString(string $unit): self
3339
default => throw new InvalidArgumentException("Invalid unit: {$unit}"),
3440
};
3541
}
36-
37-
case B = 0;
38-
case KB = 1;
39-
case MB = 2;
40-
case GB = 3;
41-
case TB = 4;
4242
}

user_guide_src/source/changelogs/v4.6.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ Model
215215
Libraries
216216
=========
217217

218+
- **File:** Added ``getSizeByBinaryUnit()`` and ``getSizeByMetricUnit()`` to ``File`` class.
219+
See :ref:`File::getSizeByBinaryUnit() <file-get-size-by-binary-unit>` and :ref:`File::getSizeByMetricUnit() <file-get-size-by-metric-unit>`.
218220
- **FileCollection:** Added ``retainMultiplePatterns()`` to ``FileCollection`` class.
219221
See :ref:`FileCollection::retainMultiplePatterns() <file-collections-retain-multiple-patterns>`.
220222
- **Validation:** Added ``min_dims`` validation rule to ``FileRules`` class. See

user_guide_src/source/libraries/files.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ the results in kibibytes or mebibytes, respectively:
6666

6767
A ``RuntimeException`` will be thrown if the file does not exist or an error occurs.
6868

69+
70+
.. _file-get-size-by-binary-unit:
71+
6972
getSizeByBinaryUnit()
7073
=====================
7174

75+
.. versionadded:: 4.6.0
76+
7277
Returns the size of the file default in bytes. You can pass in different FileSizeUnit values as the first parameter to get
7378
the results in kibibytes, mebibytes etc. respectively. You can pass in a precision value as the second parameter to define
7479
the amount of decimal places.
@@ -78,9 +83,14 @@ the amount of decimal places.
7883

7984
A ``RuntimeException`` will be thrown if the file does not exist or an error occurs.
8085

86+
87+
.. _file-get-size-by-metric-unit:
88+
8189
getSizeByMetricUnit()
8290
=====================
8391

92+
.. versionadded:: 4.6.0
93+
8494
Returns the size of the file default in bytes. You can pass in different FileSizeUnit values as the first parameter to get
8595
the results in kilobytes, megabytes etc. respectively. You can pass in a precision value as the second parameter to define
8696
the amount of decimal places.

0 commit comments

Comments
 (0)