mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 18:54:33 +00:00
Further codestyle changes
This commit is contained in:
@@ -60,5 +60,4 @@ trait CanBeBought
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
18
src/Cart.php
18
src/Cart.php
@@ -148,7 +148,7 @@ class Cart
|
||||
}
|
||||
|
||||
$content->put($item->rowId, $item);
|
||||
|
||||
|
||||
$this->events->fire('cart.added', $item);
|
||||
|
||||
$this->session->put($this->instance, $content);
|
||||
@@ -232,7 +232,7 @@ class Cart
|
||||
{
|
||||
$content = $this->getContent();
|
||||
|
||||
if ( ! $content->has($rowId)) {
|
||||
if (!$content->has($rowId)) {
|
||||
throw new InvalidRowIDException("The cart does not contain rowId {$rowId}.");
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ class Cart
|
||||
*/
|
||||
public function associate($rowId, $model)
|
||||
{
|
||||
if(is_string($model) && ! class_exists($model)) {
|
||||
if(is_string($model) && !class_exists($model)) {
|
||||
throw new UnknownModelException("The supplied model {$model} does not exist.");
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ class Cart
|
||||
/**
|
||||
* Set the global discount percentage for the cart.
|
||||
* This will set the discount for all cart items.
|
||||
*
|
||||
*
|
||||
* @param float $discount
|
||||
*
|
||||
* @return void
|
||||
@@ -597,7 +597,7 @@ class Cart
|
||||
$identifier = $identifier->getInstanceIdentifier();
|
||||
}
|
||||
|
||||
if( ! $this->storedCartWithIdentifierExists($identifier)) {
|
||||
if(!$this->storedCartWithIdentifierExists($identifier)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ class Cart
|
||||
*/
|
||||
public function merge($identifier, $keepDiscount = false, $keepTax = false)
|
||||
{
|
||||
if( ! $this->storedCartWithIdentifierExists($identifier)) {
|
||||
if(!$this->storedCartWithIdentifierExists($identifier)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -724,7 +724,7 @@ class Cart
|
||||
*/
|
||||
private function isMulti($item)
|
||||
{
|
||||
if ( ! is_array($item)) {
|
||||
if (!is_array($item)) {
|
||||
return false;
|
||||
}
|
||||
return is_array(head($item)) || head($item) instanceof Buyable;
|
||||
@@ -787,11 +787,11 @@ class Cart
|
||||
if (is_null($decimals)) {
|
||||
$decimals = config('cart.format.decimals', 2);
|
||||
}
|
||||
|
||||
|
||||
if (is_null($decimalPoint)) {
|
||||
$decimalPoint = config('cart.format.decimal_point', '.');
|
||||
}
|
||||
|
||||
|
||||
if (is_null($thousandSeperator)) {
|
||||
$thousandSeperator = config('cart.format.thousand_separator', ',');
|
||||
}
|
||||
|
||||
@@ -10,10 +10,11 @@ class CartItemOptions extends Collection
|
||||
* Get the option by the given key.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->get($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ return [
|
||||
|
||||
'decimal_point' => '.',
|
||||
|
||||
'thousand_separator' => ','
|
||||
'thousand_separator' => ',',
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
];
|
||||
|
||||
@@ -31,4 +31,4 @@ interface Buyable
|
||||
* @return float
|
||||
*/
|
||||
public function getBuyableWeight($options = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,16 @@ namespace Gloudemans\Shoppingcart\Contracts;
|
||||
interface InstanceIdentifier
|
||||
{
|
||||
/**
|
||||
* Get the unique identifier to load the Cart from
|
||||
* Get the unique identifier to load the Cart from.
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function getInstanceIdentifier($options = null);
|
||||
|
||||
/**
|
||||
* Get the unique identifier to load the Cart from
|
||||
* Get the unique identifier to load the Cart from.
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function getInstanceGlobalDiscount($options = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateShoppingcartTable extends Migration
|
||||
{
|
||||
@@ -20,6 +20,7 @@ class CreateShoppingcartTable extends Migration
|
||||
$table->primary(['identifier', 'instance']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
|
||||
@@ -4,4 +4,6 @@ namespace Gloudemans\Shoppingcart\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class CartAlreadyStoredException extends RuntimeException {}
|
||||
class CartAlreadyStoredException extends RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,4 +4,6 @@ namespace Gloudemans\Shoppingcart\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class InvalidRowIDException extends RuntimeException {}
|
||||
class InvalidRowIDException extends RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,4 +4,6 @@ namespace Gloudemans\Shoppingcart\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class UnknownModelException extends RuntimeException {}
|
||||
class UnknownModelException extends RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Gloudemans\Shoppingcart\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class Cart extends Facade {
|
||||
class Cart extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
|
||||
@@ -8,7 +8,6 @@ use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ShoppingcartServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
@@ -18,10 +17,10 @@ class ShoppingcartServiceProvider extends ServiceProvider
|
||||
{
|
||||
$this->app->bind('cart', 'Gloudemans\Shoppingcart\Cart');
|
||||
|
||||
$config = __DIR__ . '/Config/cart.php';
|
||||
$config = __DIR__.'/Config/cart.php';
|
||||
$this->mergeConfigFrom($config, 'cart');
|
||||
|
||||
$this->publishes([__DIR__ . '/Config/cart.php' => config_path('cart.php')], 'config');
|
||||
$this->publishes([__DIR__.'/Config/cart.php' => config_path('cart.php')], 'config');
|
||||
|
||||
$this->app['events']->listen(Logout::class, function () {
|
||||
if ($this->app['config']->get('cart.destroy_on_logout')) {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Gloudemans\Tests\Shoppingcart;
|
||||
|
||||
use Orchestra\Testbench\TestCase;
|
||||
use Gloudemans\Shoppingcart\CartItem;
|
||||
use Gloudemans\Shoppingcart\ShoppingcartServiceProvider;
|
||||
use Orchestra\Testbench\TestCase;
|
||||
|
||||
class CartItemTest extends TestCase
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user