Codestyle

This commit is contained in:
Patrick Henninger
2019-01-14 18:11:13 +01:00
parent 21ebf67f99
commit 862030288c
3 changed files with 32 additions and 31 deletions

View File

@@ -4,7 +4,6 @@ namespace Gloudemans\Shoppingcart;
trait CanBeBought
{
/**
* Get the identifier of the Buyable item.
*

View File

@@ -189,6 +189,7 @@ class Cart
if ($cartItem->qty <= 0) {
$this->remove($cartItem->rowId);
return;
} else {
$content->put($cartItem->rowId, $cartItem);

View File

@@ -255,8 +255,9 @@ class CartItem implements Arrayable, Jsonable
*/
public function setQuantity($qty)
{
if(empty($qty) || ! is_numeric($qty))
if (empty($qty) || !is_numeric($qty)) {
throw new \InvalidArgumentException('Please supply a valid quantity.');
}
$this->qty = $qty;
}
@@ -351,8 +352,7 @@ class CartItem implements Arrayable, Jsonable
return $this->{$attribute};
}
switch($attribute)
{
switch ($attribute) {
case 'discount':
return $this->price * ($this->discountRate / 100);
case 'priceTarget':
@@ -373,12 +373,13 @@ class CartItem implements Arrayable, Jsonable
return $this->weight * $this->qty;
case 'model':
if (isset($this->associatedModel))
if (isset($this->associatedModel)) {
return with(new $this->associatedModel)->find($this->id);
return null;
}
return;
default:
return null;
return;
}
}
@@ -456,7 +457,7 @@ class CartItem implements Arrayable, Jsonable
'options' => $this->options->toArray(),
'discount' => $this->discount,
'tax' => $this->tax,
'subtotal' => $this->subtotal
'subtotal' => $this->subtotal,
];
}