File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 1515
1616enum 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}
You can’t perform that action at this time.
0 commit comments