diff --git a/src/Calculation/DefaultCalculator.php b/src/Calculation/DefaultCalculator.php index e554fb5..5b82850 100644 --- a/src/Calculation/DefaultCalculator.php +++ b/src/Calculation/DefaultCalculator.php @@ -4,10 +4,12 @@ namespace Gloudemans\Shoppingcart\Calculation; use Gloudemans\Shoppingcart\CartItem; -class DefaultCalculator { - static function getAttribute(string $attribute, CartItem $cartItem) { +class DefaultCalculator +{ + public static function getAttribute(string $attribute, CartItem $cartItem) + { $decimals = config('cart.format.decimals', 2); - + switch ($attribute) { case 'discount': return $cartItem->price * ($cartItem->getDiscountRate() / 100); @@ -31,4 +33,4 @@ class DefaultCalculator { return; } } -} \ No newline at end of file +} diff --git a/src/Calculation/GrossPrice.php b/src/Calculation/GrossPrice.php index d622e12..1442599 100644 --- a/src/Calculation/GrossPrice.php +++ b/src/Calculation/GrossPrice.php @@ -4,10 +4,12 @@ namespace Gloudemans\Shoppingcart\Calculation; use Gloudemans\Shoppingcart\CartItem; -class GrossPrice { - static function getAttribute(string $attribute, CartItem $cartItem) { +class GrossPrice +{ + public static function getAttribute(string $attribute, CartItem $cartItem) + { $decimals = config('cart.format.decimals', 2); - + switch ($attribute) { case 'priceNet': return round($cartItem->price / (1 + ($cartItem->taxRate / 100)), $decimals); @@ -33,4 +35,4 @@ class GrossPrice { return; } } -} \ No newline at end of file +} diff --git a/src/CartItem.php b/src/CartItem.php index b73d203..dba9b8d 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -397,8 +397,8 @@ class CartItem implements Arrayable, Jsonable case 'weightTotal': return round($this->weight * $this->qty, $decimals); } - - return call_user_func(config('cart.calculator', DefaultCalculator::class) . '::getAttribute', $attribute, $this); + + return call_user_func(config('cart.calculator', DefaultCalculator::class).'::getAttribute', $attribute, $this); } /** @@ -528,4 +528,4 @@ class CartItem implements Arrayable, Jsonable { return $this->discountRate; } -} \ No newline at end of file +}