From 21ebf67f997b071d039138c2fffe6d137a0fe527 Mon Sep 17 00:00:00 2001 From: Patrick Henninger Date: Mon, 14 Jan 2019 18:05:10 +0100 Subject: [PATCH] Further codestyle changes --- src/CanBeBought.php | 3 +-- src/Cart.php | 18 +++++++++--------- src/CartItemOptions.php | 3 ++- src/Config/cart.php | 4 ++-- src/Contracts/Buyable.php | 2 +- src/Contracts/InstanceIdentifier.php | 6 +++--- ..._12_23_120000_create_shoppingcart_table.php | 5 +++-- src/Exceptions/CartAlreadyStoredException.php | 4 +++- src/Exceptions/InvalidRowIDException.php | 4 +++- src/Exceptions/UnknownModelException.php | 4 +++- src/Facades/Cart.php | 4 +++- src/ShoppingcartServiceProvider.php | 5 ++--- tests/CartItemTest.php | 2 +- 13 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/CanBeBought.php b/src/CanBeBought.php index 424461f..ef90725 100644 --- a/src/CanBeBought.php +++ b/src/CanBeBought.php @@ -60,5 +60,4 @@ trait CanBeBought return 0; } - -} \ No newline at end of file +} diff --git a/src/Cart.php b/src/Cart.php index e54084a..13bf7f9 100644 --- a/src/Cart.php +++ b/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', ','); } diff --git a/src/CartItemOptions.php b/src/CartItemOptions.php index bbd24e9..1998e69 100644 --- a/src/CartItemOptions.php +++ b/src/CartItemOptions.php @@ -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); } -} \ No newline at end of file +} diff --git a/src/Config/cart.php b/src/Config/cart.php index 1885a0a..a437d69 100644 --- a/src/Config/cart.php +++ b/src/Config/cart.php @@ -60,8 +60,8 @@ return [ 'decimal_point' => '.', - 'thousand_separator' => ',' + 'thousand_separator' => ',', ], -]; \ No newline at end of file +]; diff --git a/src/Contracts/Buyable.php b/src/Contracts/Buyable.php index 555ed7e..01134e7 100644 --- a/src/Contracts/Buyable.php +++ b/src/Contracts/Buyable.php @@ -31,4 +31,4 @@ interface Buyable * @return float */ public function getBuyableWeight($options = null); -} \ No newline at end of file +} diff --git a/src/Contracts/InstanceIdentifier.php b/src/Contracts/InstanceIdentifier.php index fc49df1..277ab89 100644 --- a/src/Contracts/InstanceIdentifier.php +++ b/src/Contracts/InstanceIdentifier.php @@ -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); -} \ No newline at end of file +} diff --git a/src/Database/migrations/2018_12_23_120000_create_shoppingcart_table.php b/src/Database/migrations/2018_12_23_120000_create_shoppingcart_table.php index fc5bb26..bc905db 100644 --- a/src/Database/migrations/2018_12_23_120000_create_shoppingcart_table.php +++ b/src/Database/migrations/2018_12_23_120000_create_shoppingcart_table.php @@ -1,8 +1,8 @@ primary(['identifier', 'instance']); }); } + /** * Reverse the migrations. */ diff --git a/src/Exceptions/CartAlreadyStoredException.php b/src/Exceptions/CartAlreadyStoredException.php index cd12259..a3ddcce 100644 --- a/src/Exceptions/CartAlreadyStoredException.php +++ b/src/Exceptions/CartAlreadyStoredException.php @@ -4,4 +4,6 @@ namespace Gloudemans\Shoppingcart\Exceptions; use RuntimeException; -class CartAlreadyStoredException extends RuntimeException {} \ No newline at end of file +class CartAlreadyStoredException extends RuntimeException +{ +} diff --git a/src/Exceptions/InvalidRowIDException.php b/src/Exceptions/InvalidRowIDException.php index c475049..df42cb9 100644 --- a/src/Exceptions/InvalidRowIDException.php +++ b/src/Exceptions/InvalidRowIDException.php @@ -4,4 +4,6 @@ namespace Gloudemans\Shoppingcart\Exceptions; use RuntimeException; -class InvalidRowIDException extends RuntimeException {} \ No newline at end of file +class InvalidRowIDException extends RuntimeException +{ +} diff --git a/src/Exceptions/UnknownModelException.php b/src/Exceptions/UnknownModelException.php index c98a3fd..c9a8a27 100644 --- a/src/Exceptions/UnknownModelException.php +++ b/src/Exceptions/UnknownModelException.php @@ -4,4 +4,6 @@ namespace Gloudemans\Shoppingcart\Exceptions; use RuntimeException; -class UnknownModelException extends RuntimeException {} \ No newline at end of file +class UnknownModelException extends RuntimeException +{ +} diff --git a/src/Facades/Cart.php b/src/Facades/Cart.php index e75e0b8..435ae85 100644 --- a/src/Facades/Cart.php +++ b/src/Facades/Cart.php @@ -1,9 +1,11 @@ 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')) { diff --git a/tests/CartItemTest.php b/tests/CartItemTest.php index 5592087..9e7457a 100644 --- a/tests/CartItemTest.php +++ b/tests/CartItemTest.php @@ -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 {