Skip to content

Commit 5282aa3

Browse files
committed
replace pow with expression
1 parent 8296dc3 commit 5282aa3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

system/Files/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function getDestination(string $destination, string $delimiter = '_', int
222222
protected function getSizeByUnitInternal(int $fileSizeBase, FileSizeUnit $unit, int $precision)
223223
{
224224
$exponent = $unit->value;
225-
$divider = pow($fileSizeBase, $exponent);
225+
$divider = $fileSizeBase ** $exponent;
226226

227227
$size = $this->getSize() / $divider;
228228

tests/system/Files/FileTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testGetSizeReturnsBytes(): void
118118
*/
119119
public function testGetSizeBinary(FileSizeUnit $unit): void
120120
{
121-
$divider = pow(1024, $unit->value);
121+
$divider = 1024 ** $unit->value;
122122
$file = new File(SYSTEMPATH . 'Common.php');
123123
$size = number_format(filesize(SYSTEMPATH . 'Common.php') / $divider, 3);
124124
$this->assertSame($size, $file->getSizeByUnitBinary($unit));
@@ -136,7 +136,7 @@ public function testGetSizeBinaryBytes(): void
136136
*/
137137
public function testGetSizeMetric(FileSizeUnit $unit): void
138138
{
139-
$divider = pow(1000, $unit->value);
139+
$divider = 1000 ** $unit->value;
140140
$file = new File(SYSTEMPATH . 'Common.php');
141141
$size = number_format(filesize(SYSTEMPATH . 'Common.php') / $divider, 3);
142142
$this->assertSame($size, $file->getSizeByUnitMetric($unit));

0 commit comments

Comments
 (0)