Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
lukepolo authored and StyleCIBot committed Jan 27, 2018
1 parent 5c1d443 commit 824f857
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
6 changes: 4 additions & 2 deletions src/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ public function getDiscount($format = true)
);
}

public function addCoupon(CouponContract $coupon) {
public function addCoupon(CouponContract $coupon)
{
$coupon->appliedToCart = false;
app('laracart')->addCoupon($coupon);
$this->code = $coupon->code;
Expand All @@ -286,8 +287,9 @@ public function addCoupon(CouponContract $coupon) {
/**
* Gets the tax for the item.
*
* @param int $amountNotTaxable
* @param int $amountNotTaxable
* @param bool $grossTax
*
* @return int|mixed
*/
public function tax($amountNotTaxable = 0, $grossTax = true)
Expand Down
3 changes: 1 addition & 2 deletions src/Contracts/CouponContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ public function __construct($code, $value);
*/
public function discount();


/**
* If an item is supplied it will get its discount value
* If an item is supplied it will get its discount value.
*
* @param CartItem $cartItem
*
Expand Down
5 changes: 3 additions & 2 deletions src/Coupons/Fixed.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ public function discount($throwErrors = false)
}

/**
* If an item is supplied it will get its discount value
* If an item is supplied it will get its discount value.
*
* @param CartItem $item
*
* @return float
*/
public function forItem(CartItem $item) {
public function forItem(CartItem $item)
{
return $item->price - $this->value;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Coupons/Percentage.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ public function __construct($code, $value, $options = [])
}

/**
* If an item is supplied it will get its discount value
* If an item is supplied it will get its discount value.
*
* @param CartItem $item
*
* @return float
*/
public function forItem(CartItem $item) {
public function forItem(CartItem $item)
{
return $item->price * $this->value;
}

Expand Down
16 changes: 9 additions & 7 deletions src/LaraCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,15 @@ public function removeAttribute($attribute)
* Creates a CartItem and then adds it to cart.
*
* @param string|int $itemID
* @param null $name
* @param int $qty
* @param string $price
* @param array $options
* @param bool|true $taxable
* @param null $name
* @param int $qty
* @param string $price
* @param array $options
* @param bool|true $taxable
*
* @return CartItem
* @throws ModelNotFound
*
* @return CartItem
*/
public function addLine($itemID, $name = null, $qty = 1, $price = '0.00', $options = [], $taxable = true)
{
Expand Down Expand Up @@ -562,7 +563,8 @@ public function removeFees()
*
* @param bool|true $format
* @param bool|true $withFees
* @param bool $grossTaxes
* @param bool $grossTaxes
*
* @return string
*/
public function taxTotal($format = true, $withFees = true, $grossTaxes = true)
Expand Down
6 changes: 3 additions & 3 deletions tests/Coupons/Fixed.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public function discount($throwErrors = false)
throw new CouponException('Sorry, you must have at least 100 dollars!');
}


/**
* If an item is supplied it will get its discount value
* If an item is supplied it will get its discount value.
*
* @param CartItem $item
*
* @return float
*/
public function forItem(CartItem $item) {
public function forItem(CartItem $item)
{
return $item->price - $this->value;
}

Expand Down
7 changes: 4 additions & 3 deletions tests/TotalsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,14 @@ public function testTaxationOnCoupons()
$this->assertEquals(6639.12, $this->laracart->total(false));
}

public function testTaxationAndDiscount() {
public function testTaxationAndDiscount()
{
$this->app['config']->set('laracart.tax', .19);
$this->app['config']->set('laracart.tax_by_item', true);
$this->app['config']->set('laracart.discountTaxable', false);
$this->app['config']->set('laracart.discountsAlreadyTaxed', true);

/** @var \LukePOLO\LaraCart\CartItem $item */
/* @var \LukePOLO\LaraCart\CartItem $item */
$this->laracart->add(
1,
'Product with 19% Tax',
Expand All @@ -321,7 +322,7 @@ public function testTaxationAndDiscount() {
\LukePOLO\LaraCart\CartItem::ITEM_TAX => .19,
]
)->addCoupon(new \LukePOLO\LaraCart\Coupons\Fixed('50EUR', 50, [
'description' => '50EUR'
'description' => '50EUR',
]));

$this->assertEquals(50, $this->laracart->subTotal(false));
Expand Down

0 comments on commit 824f857

Please sign in to comment.