Skip to content

Commit

Permalink
Merge pull request #28 from lukepolo/dev
Browse files Browse the repository at this point in the history
Fixing issue if somone put items into the subItem Array
  • Loading branch information
lukepolo committed Nov 10, 2015
2 parents 89752b2 + d70c480 commit 918eb54
Show file tree
Hide file tree
Showing 6 changed files with 525 additions and 474 deletions.
977 changes: 510 additions & 467 deletions build/logs/clover.xml

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/CartSubItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
class CartSubItem
{
const ITEMS = 'items';

use CartOptionsMagicMethodsTrait;

private $itemHash;
Expand All @@ -26,10 +28,16 @@ class CartSubItem
public function __construct($options)
{
$this->itemHash = app(LaraCart::HASH, $options);
if (isset($options[LaraCart::PRICE]) === true) {
if (isset($options[LaraCart::PRICE])) {
$this->price = $options[LaraCart::PRICE];
array_forget($options, LaraCart::PRICE);
}

if (isset($options[self::ITEMS])) {
$this->items = $options[self::ITEMS];
array_forget($options, self::ITEMS);
}

$this->options = $options;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Coupons/Percentage.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public function discount()
*/
public function displayValue()
{
return ($this->value * 100).'%';
return ($this->value * 100) . '%';
}
}
4 changes: 2 additions & 2 deletions src/LaraCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function setInstance($instance = 'default')
*/
public function get($instance = 'default')
{
if (empty($this->cart = \Session::get(config('laracart.cache_prefix', 'laracart.').$instance))) {
if (empty($this->cart = \Session::get(config('laracart.cache_prefix', 'laracart.') . $instance))) {
$this->cart = new Cart($instance);
}

Expand All @@ -67,7 +67,7 @@ public function get($instance = 'default')
*/
public function update()
{
\Session::set(config('laracart.cache_prefix', 'laracart.').$this->cart->instance, $this->cart);
\Session::set(config('laracart.cache_prefix', 'laracart.') . $this->cart->instance, $this->cart);

\Event::fire('laracart.update', $this->cart);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LaraCartServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function boot()
{
$this->publishes(
[
__DIR__.'/config/laracart.php' => config_path('laracart.php'),
__DIR__ . '/config/laracart.php' => config_path('laracart.php'),
]
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/CouponTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function checkMinAmount($minAmount, $throwErrors)
return true;
} else {
if ($throwErrors) {
throw new \Exception('You must have at least a total of '.LaraCart::formatMoney($minAmount));
throw new \Exception('You must have at least a total of ' . LaraCart::formatMoney($minAmount));
} else {
return false;
}
Expand All @@ -75,7 +75,7 @@ public function maxDiscount($maxDiscount, $discount, $throwErrors)
return $discount;
} else {
if ($throwErrors) {
throw new \Exception('This has a max discount of '.LaraCart::formatMoney($maxDiscount));
throw new \Exception('This has a max discount of ' . LaraCart::formatMoney($maxDiscount));
} else {
return $maxDiscount;
}
Expand Down

0 comments on commit 918eb54

Please sign in to comment.