diff --git a/system/Files/File.php b/system/Files/File.php index 93710e72ffc5..4c1757a6b538 100644 --- a/system/Files/File.php +++ b/system/Files/File.php @@ -73,7 +73,6 @@ public function getSize() /** * Retrieve the file size by unit, calculated in IEC standards with 1024 as base value. * - * @param FileSizeUnit $unit * @phpstan-param positive-int $precision * @return false|int|string */ @@ -85,7 +84,6 @@ public function getSizeByUnitBinary(FileSizeUnit $unit = FileSizeUnit::B, int $p /** * Retrieve the file size by unit, calculated in metric standards with 1000 as base value. * - * @param FileSizeUnit $unit * @phpstan-param positive-int $precision * @return false|int|string */ @@ -222,12 +220,10 @@ public function getDestination(string $destination, string $delimiter = '_', int protected function getSizeByUnitInternal(int $fileSizeBase, FileSizeUnit $unit, int $precision) { $exponent = $unit->value; - $divider = $fileSizeBase ** $exponent; + $divider = $fileSizeBase ** $exponent; + $size = $this->getSize() / $divider; - $size = $this->getSize() / $divider; - - if($unit !== FileSizeUnit::B) - { + if($unit !== FileSizeUnit::B) { $size = number_format($size, $precision); } diff --git a/system/Files/FileSizeUnit.php b/system/Files/FileSizeUnit.php index 8f30eeb00d8f..4098e3a3e2bb 100644 --- a/system/Files/FileSizeUnit.php +++ b/system/Files/FileSizeUnit.php @@ -13,11 +13,11 @@ namespace CodeIgniter\Files; -enum FileSizeUnit : int +enum FileSizeUnit: int { case B = 0; case KB = 1; case MB = 2; case GB = 3; case TB = 4; -} \ No newline at end of file +} diff --git a/tests/system/Files/FileTest.php b/tests/system/Files/FileTest.php index 15ac0d52f4f5..c8a15fce29af 100644 --- a/tests/system/Files/FileTest.php +++ b/tests/system/Files/FileTest.php @@ -170,7 +170,7 @@ public function testGetDestination(): void } /** - * @return array> + * @return array> */ public static function provideGetSizeData() {