mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-24 07:55:35 +00:00
StyleCI
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace Gloudemans\Shoppingcart;
|
||||
|
||||
use Gloudemans\Shoppingcart\CartItemOptions;
|
||||
use Money\Money;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
|
||||
trait CanBeBought
|
||||
{
|
||||
|
||||
20
src/Cart.php
20
src/Cart.php
@@ -2,11 +2,8 @@
|
||||
|
||||
namespace Gloudemans\Shoppingcart;
|
||||
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
use Carbon\Carbon;
|
||||
use Money\Money;
|
||||
use Money\Currency;
|
||||
use Closure;
|
||||
use Gloudemans\Shoppingcart\Contracts\Buyable;
|
||||
use Gloudemans\Shoppingcart\Contracts\InstanceIdentifier;
|
||||
use Gloudemans\Shoppingcart\Exceptions\CartAlreadyStoredException;
|
||||
@@ -17,8 +14,11 @@ use Illuminate\Database\DatabaseManager;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use InvalidArgumentException;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
|
||||
class Cart
|
||||
{
|
||||
@@ -363,7 +363,7 @@ class Cart
|
||||
if ($calculated instanceof Money) {
|
||||
return $calculated;
|
||||
} else {
|
||||
throw new \TypeError("Calculated price is not an instance of Money");
|
||||
throw new \TypeError('Calculated price is not an instance of Money');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ class Cart
|
||||
if ($calculated instanceof Money) {
|
||||
return $calculated;
|
||||
} else {
|
||||
throw new \TypeError("Calculated discount is not an instance of Money");
|
||||
throw new \TypeError('Calculated discount is not an instance of Money');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ class Cart
|
||||
if ($calculated instanceof Money) {
|
||||
return $calculated;
|
||||
} else {
|
||||
throw new \TypeError("Calculated subtotal is not an instance of Money");
|
||||
throw new \TypeError('Calculated subtotal is not an instance of Money');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ class Cart
|
||||
if ($calculated instanceof Money) {
|
||||
return $calculated;
|
||||
} else {
|
||||
throw new \TypeError("Calculated total is not an instance of Money");
|
||||
throw new \TypeError('Calculated total is not an instance of Money');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ class Cart
|
||||
if (is_int($calculated)) {
|
||||
return $calculated;
|
||||
} else {
|
||||
throw new \TypeError("Calculated weight was not an integer");
|
||||
throw new \TypeError('Calculated weight was not an integer');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ use Illuminate\Contracts\Support\Jsonable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Money\Money;
|
||||
use Money\Formatter\DecimalMoneyFormatter;
|
||||
use Money\Currencies\ISOCurrencies;
|
||||
use Money\Formatter\DecimalMoneyFormatter;
|
||||
use Money\Money;
|
||||
|
||||
class CartItem implements Arrayable, Jsonable
|
||||
{
|
||||
@@ -197,7 +197,7 @@ class CartItem implements Arrayable, Jsonable
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the tax, based on the subtotal (all previous calculations) and set tax rate
|
||||
* This is the tax, based on the subtotal (all previous calculations) and set tax rate.
|
||||
*/
|
||||
public function tax(): Money
|
||||
{
|
||||
@@ -226,6 +226,7 @@ class CartItem implements Arrayable, Jsonable
|
||||
public static function fromBuyable(Buyable $item, int $qty = 1, ?CartItemOptions $options = null): self
|
||||
{
|
||||
$options = $options ?: new CartItemOptions([]);
|
||||
|
||||
return new self($item->getBuyableIdentifier($options), $item->getBuyableDescription($options), $item->getBuyablePrice($options), $qty, $item->getBuyableWeight($options), $options);
|
||||
}
|
||||
|
||||
@@ -235,6 +236,7 @@ class CartItem implements Arrayable, Jsonable
|
||||
public static function fromArray(array $attributes): self
|
||||
{
|
||||
$options = new CartItemOptions(Arr::get($attributes, 'options', []));
|
||||
|
||||
return new self($attributes['id'], $attributes['name'], $attributes['price'], $attributes['qty'], $attributes['weight'], $options);
|
||||
}
|
||||
|
||||
@@ -246,6 +248,7 @@ class CartItem implements Arrayable, Jsonable
|
||||
public static function fromAttributes(int|string $id, string $name, Money $price, int $qty = 1, int $weight = 0, ?CartItemOptions $options = null): self
|
||||
{
|
||||
$options = $options ?: new CartItemOptions([]);
|
||||
|
||||
return new self($id, $name, $price, $qty, $weight, $options);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Gloudemans\Shoppingcart;
|
||||
|
||||
use Illuminate\Auth\Events\Logout;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ShoppingcartServiceProvider extends ServiceProvider
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace Gloudemans\Tests\Shoppingcart;
|
||||
use Gloudemans\Shoppingcart\CartItem;
|
||||
use Gloudemans\Shoppingcart\CartItemOptions;
|
||||
use Gloudemans\Shoppingcart\ShoppingcartServiceProvider;
|
||||
use Orchestra\Testbench\TestCase;
|
||||
use Money\Money;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Orchestra\Testbench\TestCase;
|
||||
|
||||
class CartItemTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace Gloudemans\Tests\Shoppingcart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Money\Money;
|
||||
use Money\Currency;
|
||||
use Gloudemans\Shoppingcart\Cart;
|
||||
use Gloudemans\Shoppingcart\CartItem;
|
||||
use Gloudemans\Shoppingcart\CartItemOptions;
|
||||
@@ -15,6 +13,8 @@ use Gloudemans\Tests\Shoppingcart\Fixtures\Identifiable;
|
||||
use Gloudemans\Tests\Shoppingcart\Fixtures\ProductModel;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Orchestra\Testbench\TestCase;
|
||||
|
||||
class CartTest extends TestCase
|
||||
@@ -31,7 +31,7 @@ class CartTest extends TestCase
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
ShoppingcartServiceProvider::class
|
||||
ShoppingcartServiceProvider::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace Gloudemans\Tests\Shoppingcart\Fixtures;
|
||||
|
||||
use Gloudemans\Shoppingcart\Contracts\Buyable;
|
||||
use Gloudemans\Shoppingcart\CartItemOptions;
|
||||
use Gloudemans\Shoppingcart\Contracts\Buyable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Money\Money;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
|
||||
class BuyableProduct extends Model implements Buyable
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user