From 13238f9883705d7c888b520a0d0d3bb2a6a23165 Mon Sep 17 00:00:00 2001 From: Patrick Henninger Date: Wed, 9 Jan 2019 12:22:21 +0100 Subject: [PATCH] Revert "Removed unnecessary assignments" This reverts commit dbfe5e01fd4c23393fa812388fc9eadef785a55b. --- src/Cart.php | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/Cart.php b/src/Cart.php index 25f925a..2d23481 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -262,7 +262,9 @@ class Cart */ public function count() { - return $this->getContent()->sum('qty'); + $content = $this->getContent(); + + return $content->sum('qty'); } /** @@ -272,7 +274,9 @@ class Cart */ public function countInstances() { - return $this->getContent()->count(); + $content = $this->getContent(); + + return $content->count(); } /** @@ -282,9 +286,13 @@ class Cart */ public function totalFloat() { - return $this->getContent()->reduce(function ($total, CartItem $cartItem) { + $content = $this->getContent(); + + $total = $content->reduce(function ($total, CartItem $cartItem) { return $total + $cartItem->total; }, 0); + + return $total; } /** @@ -307,9 +315,13 @@ class Cart */ public function taxFloat() { - return $this->getContent()->reduce(function ($tax, CartItem $cartItem) { + $content = $this->getContent(); + + $tax = $content->reduce(function ($tax, CartItem $cartItem) { return $tax + $cartItem->taxTotal; }, 0); + + return $tax; } /** @@ -332,9 +344,13 @@ class Cart */ public function subtotalFloat() { - return $this->getContent()->reduce(function ($subTotal, CartItem $cartItem) { + $content = $this->getContent(); + + $subTotal = $content->reduce(function ($subTotal, CartItem $cartItem) { return $subTotal + $cartItem->subtotal; }, 0); + + return $subTotal; } /** @@ -357,9 +373,13 @@ class Cart */ public function discountFloat() { - return $this->getContent()->reduce(function ($discount, CartItem $cartItem) { + $content = $this->getContent(); + + $discount = $content->reduce(function ($discount, CartItem $cartItem) { return $discount + $cartItem->discountTotal; }, 0); + + return $discount; } /** @@ -382,9 +402,13 @@ class Cart */ public function initialFloat() { - return $this->getContent()->reduce(function ($initial, CartItem $cartItem) { + $content = $this->getContent(); + + $initial = $content->reduce(function ($initial, CartItem $cartItem) { return $initial + ($cartItem->qty * $cartItem->price); }, 0); + + return $initial; } /** @@ -407,9 +431,11 @@ class Cart */ public function weightFloat() { - return $this->getContent()->reduce(function ($total, CartItem $cartItem) { + $content = $this->getContent(); + $total = $content->reduce(function ($total, CartItem $cartItem) { return $total + ($cartItem->qty * $cartItem->weight); }, 0); + return $total; } /** @@ -433,7 +459,9 @@ class Cart */ public function search(Closure $search) { - return $this->getContent()->filter($search); + $content = $this->getContent(); + + return $content->filter($search); } /**