Skip to content

Commit

Permalink
replace pow with expression
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMeschke committed Nov 18, 2024
1 parent 8296dc3 commit 5282aa3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion system/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function getDestination(string $destination, string $delimiter = '_', int
protected function getSizeByUnitInternal(int $fileSizeBase, FileSizeUnit $unit, int $precision)
{
$exponent = $unit->value;
$divider = pow($fileSizeBase, $exponent);
$divider = $fileSizeBase ** $exponent;

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

Expand Down
4 changes: 2 additions & 2 deletions tests/system/Files/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function testGetSizeReturnsBytes(): void
*/
public function testGetSizeBinary(FileSizeUnit $unit): void
{
$divider = pow(1024, $unit->value);
$divider = 1024 ** $unit->value;
$file = new File(SYSTEMPATH . 'Common.php');
$size = number_format(filesize(SYSTEMPATH . 'Common.php') / $divider, 3);
$this->assertSame($size, $file->getSizeByUnitBinary($unit));
Expand All @@ -136,7 +136,7 @@ public function testGetSizeBinaryBytes(): void
*/
public function testGetSizeMetric(FileSizeUnit $unit): void
{
$divider = pow(1000, $unit->value);
$divider = 1000 ** $unit->value;
$file = new File(SYSTEMPATH . 'Common.php');
$size = number_format(filesize(SYSTEMPATH . 'Common.php') / $divider, 3);
$this->assertSame($size, $file->getSizeByUnitMetric($unit));
Expand Down

0 comments on commit 5282aa3

Please sign in to comment.