Skip to content

Commit 40f6d7b

Browse files
committed
refactor FileSizeUnit enum
* reorder cases and function * add DocBlock for return and throws
1 parent f1464e3 commit 40f6d7b

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

system/Files/FileSizeUnit.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515

1616
enum FileSizeUnit: int
1717
{
18-
case B = 0;
19-
case KB = 1;
20-
case MB = 2;
21-
case GB = 3;
22-
case TB = 4;
23-
18+
/**
19+
* Allows the creation of a FileSizeUnit from Strings like "kb" or "mb"
20+
*
21+
* @return FileSizeUnit
22+
*
23+
* @throws \InvalidArgumentException
24+
*/
2425
public static function fromString(string $unit): self
2526
{
2627
return match (strtolower($unit)) {
@@ -29,7 +30,13 @@ public static function fromString(string $unit): self
2930
'mb' => self::MB,
3031
'gb' => self::GB,
3132
'tb' => self::TB,
32-
default => throw new InvalidArgumentException("Invalid unit: $unit"),
33+
default => throw new \InvalidArgumentException("Invalid unit: $unit"),
3334
};
3435
}
36+
37+
case B = 0;
38+
case KB = 1;
39+
case MB = 2;
40+
case GB = 3;
41+
case TB = 4;
3542
}

0 commit comments

Comments
 (0)