File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed
Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 1313
1414namespace CodeIgniter \Files ;
1515
16- use InvalidArgumentException ;
16+ use CodeIgniter \ Exceptions \ InvalidArgumentException ;
1717
1818enum 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}
Original file line number Diff line number Diff line change @@ -215,6 +215,8 @@ Model
215215Libraries
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
Original file line number Diff line number Diff line change @@ -66,9 +66,14 @@ the results in kibibytes or mebibytes, respectively:
6666
6767A ``RuntimeException `` will be thrown if the file does not exist or an error occurs.
6868
69+
70+ .. _file-get-size-by-binary-unit :
71+
6972getSizeByBinaryUnit()
7073=====================
7174
75+ .. versionadded :: 4.6.0
76+
7277Returns the size of the file default in bytes. You can pass in different FileSizeUnit values as the first parameter to get
7378the results in kibibytes, mebibytes etc. respectively. You can pass in a precision value as the second parameter to define
7479the amount of decimal places.
@@ -78,9 +83,14 @@ the amount of decimal places.
7883
7984A ``RuntimeException `` will be thrown if the file does not exist or an error occurs.
8085
86+
87+ .. _file-get-size-by-metric-unit :
88+
8189getSizeByMetricUnit()
8290=====================
8391
92+ .. versionadded :: 4.6.0
93+
8494Returns the size of the file default in bytes. You can pass in different FileSizeUnit values as the first parameter to get
8595the results in kilobytes, megabytes etc. respectively. You can pass in a precision value as the second parameter to define
8696the amount of decimal places.
You can’t perform that action at this time.
0 commit comments