Revert "Removed unnecessary assignments"

This reverts commit dbfe5e01fd.
This commit is contained in:
Patrick Henninger
2019-01-09 12:22:21 +01:00
parent dcab743407
commit 13238f9883

View File

@@ -262,7 +262,9 @@ class Cart
*/ */
public function count() public function count()
{ {
return $this->getContent()->sum('qty'); $content = $this->getContent();
return $content->sum('qty');
} }
/** /**
@@ -272,7 +274,9 @@ class Cart
*/ */
public function countInstances() public function countInstances()
{ {
return $this->getContent()->count(); $content = $this->getContent();
return $content->count();
} }
/** /**
@@ -282,9 +286,13 @@ class Cart
*/ */
public function totalFloat() 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; return $total + $cartItem->total;
}, 0); }, 0);
return $total;
} }
/** /**
@@ -307,9 +315,13 @@ class Cart
*/ */
public function taxFloat() 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; return $tax + $cartItem->taxTotal;
}, 0); }, 0);
return $tax;
} }
/** /**
@@ -332,9 +344,13 @@ class Cart
*/ */
public function subtotalFloat() 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; return $subTotal + $cartItem->subtotal;
}, 0); }, 0);
return $subTotal;
} }
/** /**
@@ -357,9 +373,13 @@ class Cart
*/ */
public function discountFloat() 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; return $discount + $cartItem->discountTotal;
}, 0); }, 0);
return $discount;
} }
/** /**
@@ -382,9 +402,13 @@ class Cart
*/ */
public function initialFloat() 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); return $initial + ($cartItem->qty * $cartItem->price);
}, 0); }, 0);
return $initial;
} }
/** /**
@@ -407,9 +431,11 @@ class Cart
*/ */
public function weightFloat() 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); return $total + ($cartItem->qty * $cartItem->weight);
}, 0); }, 0);
return $total;
} }
/** /**
@@ -433,7 +459,9 @@ class Cart
*/ */
public function search(Closure $search) public function search(Closure $search)
{ {
return $this->getContent()->filter($search); $content = $this->getContent();
return $content->filter($search);
} }
/** /**