From f87fd88e4da3374e6e53b1fb48d0ef68e1802d86 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 6 Sep 2023 01:14:16 +0100 Subject: [PATCH] Run Laravel Pint --- src/Console/Commands/MigrateOrderStatuses.php | 2 +- src/Console/Commands/MigrateOrdersToDatabase.php | 2 +- src/Contracts/Gateway.php | 5 ----- src/Coupons/Coupon.php | 2 +- src/Http/Controllers/CartItemController.php | 8 ++++---- src/Http/Controllers/CheckoutController.php | 2 +- src/Http/Requests/Cart/UpdateRequest.php | 2 +- src/Listeners/EnforceEntryBlueprintFields.php | 6 +++--- src/Orders/HasLineItems.php | 4 ++-- src/Products/Product.php | 2 +- src/Products/ProductVariant.php | 2 +- src/Tags/CartTags.php | 2 +- src/Tags/CheckoutTags.php | 2 +- src/Tags/CouponTags.php | 2 +- src/Tax/Standard/TaxCategory.php | 2 +- src/Tax/Standard/TaxRate.php | 2 +- src/Tax/Standard/TaxZone.php | 2 +- 17 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/Console/Commands/MigrateOrderStatuses.php b/src/Console/Commands/MigrateOrderStatuses.php index c974c2701..456d30883 100644 --- a/src/Console/Commands/MigrateOrderStatuses.php +++ b/src/Console/Commands/MigrateOrderStatuses.php @@ -18,7 +18,7 @@ class MigrateOrderStatuses extends Command { - use RunsInPlease, ConfirmableTrait; + use ConfirmableTrait, RunsInPlease; protected $name = 'sc:migrate-order-statuses'; diff --git a/src/Console/Commands/MigrateOrdersToDatabase.php b/src/Console/Commands/MigrateOrdersToDatabase.php index 5ed1f1e2f..1b9a8bd18 100644 --- a/src/Console/Commands/MigrateOrdersToDatabase.php +++ b/src/Console/Commands/MigrateOrdersToDatabase.php @@ -17,7 +17,7 @@ class MigrateOrdersToDatabase extends Command { - use RunsInPlease, ConfirmableTrait; + use ConfirmableTrait, RunsInPlease; protected $name = 'sc:migrate-to-database'; diff --git a/src/Contracts/Gateway.php b/src/Contracts/Gateway.php index b73e96fc9..6dd965f5f 100644 --- a/src/Contracts/Gateway.php +++ b/src/Contracts/Gateway.php @@ -24,8 +24,6 @@ public function isOffsiteGateway(): bool; * * If you're building an off-site gateway, you should return a `checkout_url` key with the * URL the user should be redirected to for checkout. - * - * @param \DoubleThreeDigital\SimpleCommerce\Contracts\Order $order */ public function prepare(Request $request, Order $order): array; @@ -36,8 +34,6 @@ public function prepare(Request $request, Order $order): array; * If you need to display an error message, you should throw a GatewayCheckoutFailed exception. * * If you're building an off-site gateway, you don't need to implement this method. - * - * @param \DoubleThreeDigital\SimpleCommerce\Contracts\Order $order */ public function checkout(Request $request, Order $order): array; @@ -62,7 +58,6 @@ public function checkoutMessages(): array; * return an array of any data which may prove helpful in the future to track down * refunds (like a Refund ID). * - * @param \DoubleThreeDigital\SimpleCommerce\Contracts\Order $order * @return array|null */ public function refund(Order $order): array; diff --git a/src/Coupons/Coupon.php b/src/Coupons/Coupon.php index af4cad8e7..aacc50073 100644 --- a/src/Coupons/Coupon.php +++ b/src/Coupons/Coupon.php @@ -17,7 +17,7 @@ class Coupon implements Contract { - use FluentlyGetsAndSets, ExistsAsFile, TracksQueriedColumns, ContainsData; + use ContainsData, ExistsAsFile, FluentlyGetsAndSets, TracksQueriedColumns; public $id; diff --git a/src/Http/Controllers/CartItemController.php b/src/Http/Controllers/CartItemController.php index 962b6295e..79790fb07 100644 --- a/src/Http/Controllers/CartItemController.php +++ b/src/Http/Controllers/CartItemController.php @@ -108,13 +108,13 @@ public function store(StoreRequest $request) // Ensure there's enough stock to fulfill the customer's quantity if ($product->purchasableType() === ProductType::Product) { - if (is_int($product->stock()) && $product->stock() < $request->quantity) { + if (is_int($product->stock()) && $request->quantity > $product->stock()) { return $this->withErrors($request, __("There's not enough stock to fulfil the quantity you selected. Please try again later.")); } } elseif ($product->purchasableType() === ProductType::Variant) { $variant = $product->variant($request->get('variant')); - if ($variant !== null && is_int($variant->stock()) && $variant->stock() < $request->quantity) { + if ($variant !== null && is_int($variant->stock()) && $request->quantity > $variant->stock()) { return $this->withErrors($request, __("There's not enough stock to fulfil the quantity you selected. Please try again later.")); } } @@ -212,7 +212,7 @@ public function update(UpdateRequest $request, string $requestItem) // Ensure there's enough stock to fulfill the customer's quantity if ($product->purchasableType() === ProductType::Product) { - if (is_int($product->stock()) && $product->stock() < $request->quantity) { + if (is_int($product->stock()) && $request->quantity > $product->stock()) { return $this->withErrors($request, __("There's not enough stock to fulfil the quantity you selected. Please try again later.")); } } elseif ($product->purchasableType() === ProductType::Variant) { @@ -220,7 +220,7 @@ public function update(UpdateRequest $request, string $requestItem) ? $product->variant($request->get('variant')) : $product->variant($lineItem->variant()['variant']); - if ($variant !== null && is_int($variant->stock()) && $variant->stock() < $request->quantity) { + if ($variant !== null && is_int($variant->stock()) && $request->quantity > $variant->stock()) { return $this->withErrors($request, __("There's not enough stock to fulfil the quantity you selected. Please try again later.")); } } diff --git a/src/Http/Controllers/CheckoutController.php b/src/Http/Controllers/CheckoutController.php index 2c2972d2a..54297809b 100644 --- a/src/Http/Controllers/CheckoutController.php +++ b/src/Http/Controllers/CheckoutController.php @@ -26,7 +26,7 @@ class CheckoutController extends BaseActionController { - use CartDriver, AcceptsFormRequests; + use AcceptsFormRequests, CartDriver; public $order; diff --git a/src/Http/Requests/Cart/UpdateRequest.php b/src/Http/Requests/Cart/UpdateRequest.php index bb8ff3613..2f0f932d2 100644 --- a/src/Http/Requests/Cart/UpdateRequest.php +++ b/src/Http/Requests/Cart/UpdateRequest.php @@ -8,7 +8,7 @@ class UpdateRequest extends FormRequest { - use CartDriver, AcceptsFormRequests; + use AcceptsFormRequests, CartDriver; public function authorize() { diff --git a/src/Listeners/EnforceEntryBlueprintFields.php b/src/Listeners/EnforceEntryBlueprintFields.php index 5c87de0a5..9e4a673db 100644 --- a/src/Listeners/EnforceEntryBlueprintFields.php +++ b/src/Listeners/EnforceEntryBlueprintFields.php @@ -19,16 +19,16 @@ public function handle(EntryBlueprintFound $event) if ( $this->isOrExtendsClass($customerDriver['repository'], EntryCustomerRepository::class) - && $event->blueprint->namespace() === "collections.{$customerDriver['collection']}" + && "collections.{$customerDriver['collection']}" === $event->blueprint->namespace() ) { return $this->enforceCustomerFields($event); } - if (isset($productDriver['collection']) && $event->blueprint->namespace() === "collections.{$productDriver['collection']}") { + if (isset($productDriver['collection']) && "collections.{$productDriver['collection']}" === $event->blueprint->namespace()) { return $this->enforceProductFields($event); } - if (isset($orderDriver['collection']) && $event->blueprint->namespace() === "collections.{$orderDriver['collection']}") { + if (isset($orderDriver['collection']) && "collections.{$orderDriver['collection']}" === $event->blueprint->namespace()) { return $this->enforceOrderFields($event); } } diff --git a/src/Orders/HasLineItems.php b/src/Orders/HasLineItems.php index 1802419eb..88b701ef2 100644 --- a/src/Orders/HasLineItems.php +++ b/src/Orders/HasLineItems.php @@ -103,7 +103,7 @@ public function addLineItem(array $lineItemData): LineItem public function updateLineItem($lineItemId, array $lineItemData): LineItem { $this->lineItems = $this->lineItems->map(function ($item) use ($lineItemId, $lineItemData) { - if ($item->id() !== $lineItemId) { + if ($lineItemId !== $item->id()) { return $item; } @@ -148,7 +148,7 @@ public function updateLineItem($lineItemId, array $lineItemData): LineItem public function removeLineItem($lineItemId): Collection { $this->lineItems = $this->lineItems->reject(function ($item) use ($lineItemId) { - return $item->id() === $lineItemId; + return $lineItemId === $item->id(); })->values(); $this->save(); diff --git a/src/Products/Product.php b/src/Products/Product.php index ad4f35dd9..eb5683ad8 100644 --- a/src/Products/Product.php +++ b/src/Products/Product.php @@ -150,7 +150,7 @@ public function variantOptions(): Collection public function variant(string $optionKey): ?ProductVariant { return $this->variantOptions()->filter(function ($variant) use ($optionKey) { - return $variant->key() === $optionKey; + return $optionKey === $variant->key(); })->first(); } diff --git a/src/Products/ProductVariant.php b/src/Products/ProductVariant.php index 532cb47c6..016d9f9f8 100644 --- a/src/Products/ProductVariant.php +++ b/src/Products/ProductVariant.php @@ -9,7 +9,7 @@ class ProductVariant { - use HasData, FluentlyGetsAndSets; + use FluentlyGetsAndSets, HasData; protected $key; diff --git a/src/Tags/CartTags.php b/src/Tags/CartTags.php index 86e8e4fc1..91dd76f2c 100644 --- a/src/Tags/CartTags.php +++ b/src/Tags/CartTags.php @@ -11,8 +11,8 @@ class CartTags extends SubTag { - use Concerns\FormBuilder; use CartDriver; + use Concerns\FormBuilder; public function index() { diff --git a/src/Tags/CheckoutTags.php b/src/Tags/CheckoutTags.php index d2c789ab4..866a0989c 100644 --- a/src/Tags/CheckoutTags.php +++ b/src/Tags/CheckoutTags.php @@ -16,8 +16,8 @@ class CheckoutTags extends SubTag { - use Concerns\FormBuilder; use CartDriver; + use Concerns\FormBuilder; public function index() { diff --git a/src/Tags/CouponTags.php b/src/Tags/CouponTags.php index a523e23c1..61e6eaf5e 100644 --- a/src/Tags/CouponTags.php +++ b/src/Tags/CouponTags.php @@ -7,8 +7,8 @@ class CouponTags extends SubTag { - use Concerns\FormBuilder; use CartDriver; + use Concerns\FormBuilder; public function index(): array { diff --git a/src/Tax/Standard/TaxCategory.php b/src/Tax/Standard/TaxCategory.php index 042c746a3..79d014f89 100644 --- a/src/Tax/Standard/TaxCategory.php +++ b/src/Tax/Standard/TaxCategory.php @@ -12,7 +12,7 @@ class TaxCategory { - use FluentlyGetsAndSets, ExistsAsFile, TracksQueriedColumns, ContainsData; + use ContainsData, ExistsAsFile, FluentlyGetsAndSets, TracksQueriedColumns; public $id; diff --git a/src/Tax/Standard/TaxRate.php b/src/Tax/Standard/TaxRate.php index e724a463f..b14a20ffa 100644 --- a/src/Tax/Standard/TaxRate.php +++ b/src/Tax/Standard/TaxRate.php @@ -13,7 +13,7 @@ class TaxRate { - use FluentlyGetsAndSets, ExistsAsFile, TracksQueriedColumns, ContainsData; + use ContainsData, ExistsAsFile, FluentlyGetsAndSets, TracksQueriedColumns; public $id; diff --git a/src/Tax/Standard/TaxZone.php b/src/Tax/Standard/TaxZone.php index 71d9ccd4e..1c37279f7 100644 --- a/src/Tax/Standard/TaxZone.php +++ b/src/Tax/Standard/TaxZone.php @@ -14,7 +14,7 @@ class TaxZone { - use FluentlyGetsAndSets, ExistsAsFile, TracksQueriedColumns, ContainsData; + use ContainsData, ExistsAsFile, FluentlyGetsAndSets, TracksQueriedColumns; public $id;