Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Number.php
  • Loading branch information
allanmcarvalho committed Nov 20, 2023
2 parents cbe4f8b + 5e85e30 commit cd954b4
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Enums/RoundMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum RoundMode: int

public function getLabel(): string
{
return match($this) {
return match ($this) {
self::HALF_UP => 'Half Up',
self::HALF_DOWN => 'Half Down',
self::HALF_EVEN => 'Half Even',
Expand Down
7 changes: 1 addition & 6 deletions src/Numerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public function divideBy(Numerable|int|float|string $divisor, callable $zeroSafe
return new static(Number::divide($this->number, Number::from($divisor)->raw(), $zeroSafeCallback));
}

/**
* @param \Numerable\Numerable|int|float|string $value
* @param bool $strict
* @return bool
*/
public function equal(Numerable|int|float|string $value, bool $strict = false): bool
{
return Number::equal($this->number, Number::from($value)->raw(), $strict);
Expand Down Expand Up @@ -175,7 +170,7 @@ public function round(int $precision = 0, int|RoundMode $mode = RoundMode::HALF_
/**
* Round the instance number as a multiple of the given value.
*/
public function roundAsMultipleOf( int|float $multiple, int|RoundMode $mode = RoundMode::HALF_UP): static
public function roundAsMultipleOf(int|float $multiple, int|RoundMode $mode = RoundMode::HALF_UP): static
{
return new static(Number::roundAsMultipleOf($this->number, $multiple, $mode));
}
Expand Down
4 changes: 1 addition & 3 deletions tests/NumberAbsTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Numerable\Number;
use Numerable\Numerable;

it('do a simple abs', function () {
expect(Number::abs(-2))
Expand All @@ -19,8 +18,7 @@
expect(num(-100)->abs()->raw())
->toBeInt()
->toEqual(100)
->and(num(-85.32)->abs()->raw())
->and(num(-85.32)->abs()->raw())
->toBeFloat()
->toEqual(85.32);
});

4 changes: 1 addition & 3 deletions tests/NumberDiffTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Numerable\Number;
use Numerable\Numerable;

it('do a simple diff', function () {
expect(Number::diff(10, 8))
Expand All @@ -19,7 +18,7 @@
expect(num(-100)->diff(100)->raw())
->toBeInt()
->toEqual(200)
->and(num(100)->diff(-100)->raw())
->and(num(100)->diff(-100)->raw())
->toBeInt()
->toEqual(200)
->and(num(100)->diff(100)->raw())
Expand All @@ -29,4 +28,3 @@
->toBeFloat()
->toEqual(1.5);
});

2 changes: 0 additions & 2 deletions tests/NumberRoundAsMultipleOfTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

use Numerable\Enums\RoundMode;
use Numerable\Number;
use Numerable\Numerable;

it('can do a simple format', function () {
expect(Number::roundAsMultipleOf(22.32, 0.1))
Expand Down
4 changes: 1 addition & 3 deletions tests/NumberVariationTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Numerable\Number;
use Numerable\Numerable;

it('can do a simple variation', function () {
expect(Number::variation(100, 80))
Expand All @@ -19,12 +18,11 @@
expect(num(100)->variationTo(80)->raw())
->toBeFloat()
->toEqual(0.2)
->and(num(80)->variationTo(100)->raw())
->and(num(80)->variationTo(100)->raw())
->toBeFloat()
->toEqual(-0.25);
});


it('calculate a variation from', function () {
expect(num(110)->variationFrom(100)->raw())
->toBeFloat()
Expand Down

0 comments on commit cd954b4

Please sign in to comment.