From 06a74f53a9d6e4d459704ebcfde30c25d9a0b465 Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 11 Feb 2022 14:37:06 +0000 Subject: [PATCH] 2.0-beta9 (#161) --- CHANGELOG.md | 17 +++++- .../2021_08_10_101547_create_media_table.php | 2 +- ...08_17_142630_create_activity_log_table.php | 2 +- ...ConvertProductTypeAttributesToProducts.php | 2 +- .../state/EnsureDefaultTaxClassExists.php | 4 +- .../state/EnsureUserOrdersHaveACustomer.php | 2 +- src/Actions/Carts/CalculateLine.php | 5 +- src/Actions/Carts/CreateOrder.php | 3 +- src/Actions/Carts/MergeCart.php | 5 +- src/Actions/Carts/ValidateCartForOrder.php | 9 ++- src/Actions/Collections/SortProducts.php | 3 +- .../Collections/SortProductsByPrice.php | 7 +-- src/Actions/Collections/SortProductsBySku.php | 5 +- src/Actions/Taxes/GetTaxZonePostcode.php | 15 ++--- src/Addons/Manifest.php | 5 +- src/Base/AttributeManifestInterface.php | 6 +- src/Base/BaseModel.php | 12 ++-- src/Base/CartSessionInterface.php | 16 ++--- src/Base/Casts/AsAttributeData.php | 10 ++-- src/Base/Casts/Price.php | 18 +++--- src/Base/Casts/TaxBreakdown.php | 18 +++--- src/Base/FieldType.php | 3 +- src/Base/FieldTypeManifest.php | 7 +-- src/Base/FieldTypeManifestInterface.php | 3 +- src/Base/OrderReferenceGenerator.php | 5 +- src/Base/OrderReferenceGeneratorInterface.php | 3 +- src/Base/PricingManagerInterface.php | 18 ++---- src/Base/ShippingManifest.php | 2 +- src/Base/ShippingManifestInterface.php | 6 +- src/Base/ShippingModifiers.php | 1 - src/Base/TaxDriver.php | 14 ++--- src/Base/Traits/CanScheduleAvailability.php | 34 +++++------ src/Base/Traits/HasCustomerGroups.php | 16 +++-- src/Base/Traits/HasDefaultRecord.php | 3 +- src/Base/Traits/HasTranslations.php | 20 +++---- src/Console/Commands/Import/AddressData.php | 4 +- src/Console/InstallGetCandy.php | 32 +++++----- src/DataTypes/Price.php | 11 ++-- src/FieldTypes/Dropdown.php | 6 +- src/FieldTypes/ListField.php | 6 +- src/FieldTypes/Number.php | 6 +- src/FieldTypes/Text.php | 6 +- src/FieldTypes/Toggle.php | 4 +- src/FieldTypes/TranslatedText.php | 6 +- src/GetCandyServiceProvider.php | 2 +- .../Collections/RebuildCollectionTree.php | 6 +- .../Collections/UpdateProductPositions.php | 2 +- src/Jobs/Products/Associations/Associate.php | 8 +-- src/Jobs/Products/Associations/Dissociate.php | 8 +-- src/Jobs/SyncTags.php | 5 +- src/Listeners/CartSessionAuthListener.php | 10 ++-- src/Managers/CartLineManager.php | 2 +- src/Managers/CartManager.php | 49 +++++++--------- src/Managers/CartSessionManager.php | 11 ++-- src/Managers/PricingManager.php | 32 +++++----- src/Managers/TaxManager.php | 3 +- src/Models/Address.php | 6 +- src/Models/Attribute.php | 5 +- src/Models/Channel.php | 3 +- src/Models/Product.php | 10 ++-- src/Models/ProductAssociation.php | 14 ++--- src/Models/Url.php | 3 +- src/Observers/CartLineObserver.php | 10 ++-- src/Observers/ChannelObserver.php | 15 ++--- src/Observers/CollectionObserver.php | 3 +- src/Observers/CurrencyObserver.php | 15 ++--- src/Observers/LanguageObserver.php | 15 ++--- src/Observers/OrderLineObserver.php | 10 ++-- src/Observers/UrlObserver.php | 12 ++-- src/Rules/MaxDecimalPlaces.php | 5 +- src/Utils/Arr.php | 2 +- tests/Unit/Base/MacroableModelTest.php | 3 +- tests/Unit/Managers/CartManagerTest.php | 58 +++++++++---------- tests/Unit/Models/ProductOptionTest.php | 2 +- tests/Unit/Models/ProductTest.php | 2 +- 75 files changed, 310 insertions(+), 403 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06204f60..fc35d5cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,15 +3,30 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -[Unreleased] +## 2.0-beta9 - 2022-02-11 ### Fixed - If an attribute value is null it will be returned instead of the `{"en": null}` encoded string. ([#130](https://github.com/getcandy/getcandy/issues/130)) +- When loading an exiting product with channel availabilty, the scheduling modal should no longer display without prompt. +- `Product` and `ProductOption` models will now take the Scout prefix config setting on the indexes. +- The `Text` fieldtype tolerance now accepts numeric values instead of just forcing strings. +- Translating an attribute via `->translateAttribute('name')` will now handle non translatable fields for consistency. +- When using the `getcandy:meilisearch:setup` only indexes available within the app should be affected. +- When installing GetCandy the correct configuration or rich text fields should now be applied. By ([@KKSzymanowski](https://github.com/KKSzymanowski)) ### Added - Added `Taxes` facade to ensure the `TaxManager` can be easily extended. ([#129](https://github.com/getcandy/getcandy/issues/129)) +- `collections` relationship has been added to the `Product` model. By ([@poppabear8883](https://github.com/poppabear8883)) +- GetCandy's models now support have added macro support. By ([@edcoreweb](https://github.com/edcoreweb)) + +### Changed + +- Instead of assuming `$user->id` we know use `$user->getKey()`. By ([@ryanmitchell](https://github.com/ryanmitchell)) +- Big maintainence update to the Docblocks across the codebase to help with IDE support. By ([@KKSzymanowski](https://github.com/KKSzymanowski)) + +[View Changes](https://github.com/getcandy/core/compare/2.0-beta8...2.0-beta9) ## 2.0-beta8 - 2022-02-01 diff --git a/database/migrations/2021_08_10_101547_create_media_table.php b/database/migrations/2021_08_10_101547_create_media_table.php index eec1a91c..54cdc8ef 100644 --- a/database/migrations/2021_08_10_101547_create_media_table.php +++ b/database/migrations/2021_08_10_101547_create_media_table.php @@ -8,7 +8,7 @@ class CreateMediaTable extends Migration { public function up() { - if (!Schema::hasTable('media')) { + if (! Schema::hasTable('media')) { Schema::create('media', function (Blueprint $table) { $table->bigIncrements('id'); diff --git a/database/migrations/2021_08_17_142630_create_activity_log_table.php b/database/migrations/2021_08_17_142630_create_activity_log_table.php index c3d7fcdd..40576f17 100644 --- a/database/migrations/2021_08_17_142630_create_activity_log_table.php +++ b/database/migrations/2021_08_17_142630_create_activity_log_table.php @@ -10,7 +10,7 @@ public function up() { $tableName = config('activitylog.table_name'); - if (!Schema::hasTable($tableName)) { + if (! Schema::hasTable($tableName)) { Schema::create($tableName, function (Blueprint $table) { $table->bigIncrements('id'); $table->string('log_name')->nullable(); diff --git a/database/state/ConvertProductTypeAttributesToProducts.php b/database/state/ConvertProductTypeAttributesToProducts.php index af72bc02..d63ee71e 100644 --- a/database/state/ConvertProductTypeAttributesToProducts.php +++ b/database/state/ConvertProductTypeAttributesToProducts.php @@ -13,7 +13,7 @@ public function run() { $prefix = config('getcandy.database.table_prefix'); - if (!$this->canRun()) { + if (! $this->canRun()) { return; } diff --git a/database/state/EnsureDefaultTaxClassExists.php b/database/state/EnsureDefaultTaxClassExists.php index 3468f39d..32b00b98 100644 --- a/database/state/EnsureDefaultTaxClassExists.php +++ b/database/state/EnsureDefaultTaxClassExists.php @@ -9,7 +9,7 @@ class EnsureDefaultTaxClassExists { public function run() { - if (!$this->canRun() || !$this->shouldRun()) { + if (! $this->canRun() || ! $this->shouldRun()) { return; } @@ -32,6 +32,6 @@ protected function canRun() protected function shouldRun() { - return !TaxClass::whereDefault(true)->count(); + return ! TaxClass::whereDefault(true)->count(); } } diff --git a/database/state/EnsureUserOrdersHaveACustomer.php b/database/state/EnsureUserOrdersHaveACustomer.php index 7aa28cc5..3a497fe0 100644 --- a/database/state/EnsureUserOrdersHaveACustomer.php +++ b/database/state/EnsureUserOrdersHaveACustomer.php @@ -10,7 +10,7 @@ class EnsureUserOrdersHaveACustomer { public function run() { - if (!$this->canRun()) { + if (! $this->canRun()) { return; } diff --git a/src/Actions/Carts/CalculateLine.php b/src/Actions/Carts/CalculateLine.php index b515ec44..1549c010 100644 --- a/src/Actions/Carts/CalculateLine.php +++ b/src/Actions/Carts/CalculateLine.php @@ -20,9 +20,8 @@ public function __construct( /** * Execute the action. * - * @param \GetCandy\Models\CartLine $cartLine - * @param \Illuminate\Database\Eloquent\Collection $customerGroups - * + * @param \GetCandy\Models\CartLine $cartLine + * @param \Illuminate\Database\Eloquent\Collection $customerGroups * @return \GetCandy\Models\CartLine */ public function execute( diff --git a/src/Actions/Carts/CreateOrder.php b/src/Actions/Carts/CreateOrder.php index bd1aaf97..c11966e2 100644 --- a/src/Actions/Carts/CreateOrder.php +++ b/src/Actions/Carts/CreateOrder.php @@ -23,8 +23,7 @@ public function __construct(OrderReferenceGeneratorInterface $generator) /** * Execute the action. * - * @param \GetCandy\Models\Cart $cart - * + * @param \GetCandy\Models\Cart $cart * @return void */ public function execute( diff --git a/src/Actions/Carts/MergeCart.php b/src/Actions/Carts/MergeCart.php index 4be0ae5a..e8380c91 100644 --- a/src/Actions/Carts/MergeCart.php +++ b/src/Actions/Carts/MergeCart.php @@ -10,9 +10,8 @@ class MergeCart /** * Execute the action. * - * @param \GetCandy\Models\Cart $target - * @param \GetCandy\Models\Cart $source - * + * @param \GetCandy\Models\Cart $target + * @param \GetCandy\Models\Cart $source * @return \GetCandy\Models\Cart */ public function execute(Cart $target, Cart $source) diff --git a/src/Actions/Carts/ValidateCartForOrder.php b/src/Actions/Carts/ValidateCartForOrder.php index 7895a1d7..224609c4 100644 --- a/src/Actions/Carts/ValidateCartForOrder.php +++ b/src/Actions/Carts/ValidateCartForOrder.php @@ -16,8 +16,7 @@ class ValidateCartForOrder /** * Execute the action. * - * @param \GetCandy\Models\Cart $cart - * + * @param \GetCandy\Models\Cart $cart * @return void */ public function execute( @@ -32,7 +31,7 @@ public function execute( } // Do we have a billing address? - if (!$cart->billingAddress) { + if (! $cart->billingAddress) { throw new BillingAddressMissingException( __('getcandy::exceptions.carts.billing_missing') ); @@ -49,7 +48,7 @@ public function execute( // Is this cart shippable and if so, does it have a shipping address. if ($cart->getManager()->isShippable()) { - if (!$cart->shippingAddress) { + if (! $cart->shippingAddress) { throw new ShippingAddressMissingException( __('getcandy::exceptions.carts.shipping_missing') ); @@ -65,7 +64,7 @@ public function execute( } // Do we have a shipping option applied? - if (!$cart->getManager()->getShippingOption()) { + if (! $cart->getManager()->getShippingOption()) { throw new ShippingOptionMissingException(); } } diff --git a/src/Actions/Collections/SortProducts.php b/src/Actions/Collections/SortProducts.php index 7047c138..dc9a12bc 100644 --- a/src/Actions/Collections/SortProducts.php +++ b/src/Actions/Collections/SortProducts.php @@ -10,8 +10,7 @@ class SortProducts /** * Execute the action. * - * @param \GetCandy\Models\Collection $collection - * + * @param \GetCandy\Models\Collection $collection * @return void */ public function execute(Collection $collection) diff --git a/src/Actions/Collections/SortProductsByPrice.php b/src/Actions/Collections/SortProductsByPrice.php index 7e71d639..aacd016e 100644 --- a/src/Actions/Collections/SortProductsByPrice.php +++ b/src/Actions/Collections/SortProductsByPrice.php @@ -11,10 +11,9 @@ class SortProductsByPrice /** * Execute the action. * - * @param \Illuminate\Support\Collection $products - * @param \GetCandy\Models\Currency $currency - * @param string $direction - * + * @param \Illuminate\Support\Collection $products + * @param \GetCandy\Models\Currency $currency + * @param string $direction * @return void */ public function execute(Collection $products, Currency $currency, $direction = 'asc') diff --git a/src/Actions/Collections/SortProductsBySku.php b/src/Actions/Collections/SortProductsBySku.php index b4d2667b..5e2c082d 100644 --- a/src/Actions/Collections/SortProductsBySku.php +++ b/src/Actions/Collections/SortProductsBySku.php @@ -9,9 +9,8 @@ class SortProductsBySku /** * Execute the action. * - * @param \Illuminate\Support\Collection $products - * @param string $direction - * + * @param \Illuminate\Support\Collection $products + * @param string $direction * @return \Illuminate\Support\Collection */ public function execute(Collection $products, $direction = 'asc') diff --git a/src/Actions/Taxes/GetTaxZonePostcode.php b/src/Actions/Taxes/GetTaxZonePostcode.php index aef61aee..929edff8 100644 --- a/src/Actions/Taxes/GetTaxZonePostcode.php +++ b/src/Actions/Taxes/GetTaxZonePostcode.php @@ -9,8 +9,7 @@ class GetTaxZonePostcode /** * Execute the action. * - * @param string $postcode - * + * @param string $postcode * @return null|\GetCandy\Models\TaxZonePostcode */ public function execute($postcode) @@ -21,7 +20,7 @@ public function execute($postcode) return $postcodeZone; } - if (!$postcodeZone) { + if (! $postcodeZone) { return null; } @@ -33,7 +32,7 @@ public function execute($postcode) })->sort(fn ($current, $next) => $current['matches'] < $next['matches'])->first(); // Give up, use default... - if (!$match) { + if (! $match) { return null; } @@ -43,8 +42,7 @@ public function execute($postcode) /** * Return the zone or zones which match this postcode. * - * @param string $postcode - * + * @param string $postcode * @return \GetCandy\Models\TaxZonePostcode|\Illuminate\Support\Collection */ protected function getZoneMatches($postcode) @@ -61,9 +59,8 @@ protected function getZoneMatches($postcode) /** * Match wildcard postcodes and return number of matches. * - * @param string $wildcard - * @param string $haystack - * + * @param string $wildcard + * @param string $haystack * @return int */ private function matchWildcard($wildcard, $haystack) diff --git a/src/Addons/Manifest.php b/src/Addons/Manifest.php index ff6ccc36..efd6fa6d 100644 --- a/src/Addons/Manifest.php +++ b/src/Addons/Manifest.php @@ -43,13 +43,12 @@ public function build() /** * Format a given composer package into our addon format. * - * @param array $package - * + * @param array $package * @return void|array */ protected function formatPackage($package) { - if (!$provider = $package['extra']['laravel']['providers'][0] ?? null) { + if (! $provider = $package['extra']['laravel']['providers'][0] ?? null) { return; } diff --git a/src/Base/AttributeManifestInterface.php b/src/Base/AttributeManifestInterface.php index eb4bcc5e..7c242baf 100644 --- a/src/Base/AttributeManifestInterface.php +++ b/src/Base/AttributeManifestInterface.php @@ -9,8 +9,7 @@ interface AttributeManifestInterface /** * Add an attribute type. * - * @param string $classname - * + * @param string $classname * @return void */ public function addType($classname); @@ -25,8 +24,7 @@ public function getTypes(): Collection; /** * Return an attribute type by it's key. * - * @param string $handle - * + * @param string $handle * @return string|null */ public function getType($handle); diff --git a/src/Base/BaseModel.php b/src/Base/BaseModel.php index 3cf9b275..00b8ad78 100644 --- a/src/Base/BaseModel.php +++ b/src/Base/BaseModel.php @@ -14,7 +14,7 @@ abstract class BaseModel extends Model /** * Create a new instance of the Model. * - * @param array $attributes + * @param array $attributes */ public function __construct(array $attributes = []) { @@ -26,9 +26,8 @@ public function __construct(array $attributes = []) /** * Handle dynamic method calls into the model. * - * @param string $method - * @param array $parameters - * + * @param string $method + * @param array $parameters * @return mixed */ public function __call($method, $parameters) @@ -43,9 +42,8 @@ public function __call($method, $parameters) /** * Handle dynamic static method calls into the model. * - * @param string $method - * @param array $parameters - * + * @param string $method + * @param array $parameters * @return mixed */ public static function __callStatic($method, $parameters) diff --git a/src/Base/CartSessionInterface.php b/src/Base/CartSessionInterface.php index 2e3c3d29..7d724b46 100644 --- a/src/Base/CartSessionInterface.php +++ b/src/Base/CartSessionInterface.php @@ -33,10 +33,9 @@ public function manager(); /** * Associate a cart to a user. * - * @param \GetCandy\Models\Cart $cart - * @param \Illuminate\Contracts\Auth\Authenticatable $user - * @param string $policy - * + * @param \GetCandy\Models\Cart $cart + * @param \Illuminate\Contracts\Auth\Authenticatable $user + * @param string $policy * @return void */ public function associate(Cart $cart, Authenticatable $user, $policy); @@ -44,8 +43,7 @@ public function associate(Cart $cart, Authenticatable $user, $policy); /** * Use the given cart and set to the session. * - * @param \GetCandy\Models\Cart $cart - * + * @param \GetCandy\Models\Cart $cart * @return void */ public function use(Cart $cart); @@ -60,8 +58,7 @@ public function getSessionKey(); /** * Set the cart session channel. * - * @param \GetCandy\Models\Channel $channel - * + * @param \GetCandy\Models\Channel $channel * @return self */ public function setChannel(Channel $channel); @@ -69,8 +66,7 @@ public function setChannel(Channel $channel); /** * Set the cart session currency. * - * @param \GetCandy\Models\Currency $currency - * + * @param \GetCandy\Models\Currency $currency * @return self */ public function setCurrency(Currency $currency); diff --git a/src/Base/Casts/AsAttributeData.php b/src/Base/Casts/AsAttributeData.php index 5dd0b250..f3c19bcd 100644 --- a/src/Base/Casts/AsAttributeData.php +++ b/src/Base/Casts/AsAttributeData.php @@ -13,16 +13,16 @@ class AsAttributeData implements Castable /** * Get the caster class to use when casting from / to this cast target. * - * @param array $arguments - * + * @param array $arguments * @return object|string */ public static function castUsing(array $arguments) { - return new class() implements CastsAttributes { + return new class() implements CastsAttributes + { public function get($model, $key, $value, $attributes) { - if (!isset($attributes[$key])) { + if (! isset($attributes[$key])) { return null; } @@ -31,7 +31,7 @@ public function get($model, $key, $value, $attributes) $returnData = new Collection(); foreach ($data as $key => $item) { - if (!in_array(FieldType::class, class_implements($item['field_type']))) { + if (! in_array(FieldType::class, class_implements($item['field_type']))) { throw new FieldTypeException('This field type is not supported.'); } $returnData->put($key, new $item['field_type']($item['value'])); diff --git a/src/Base/Casts/Price.php b/src/Base/Casts/Price.php index 8d2d1583..bf29250c 100644 --- a/src/Base/Casts/Price.php +++ b/src/Base/Casts/Price.php @@ -12,11 +12,10 @@ class Price implements CastsAttributes /** * Cast the given value. * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key - * @param mixed $value - * @param array $attributes - * + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key + * @param mixed $value + * @param array $attributes * @return \GetCandy\DataTypes\Price */ public function get($model, $key, $value, $attributes) @@ -47,11 +46,10 @@ public function get($model, $key, $value, $attributes) /** * Prepare the given value for storage. * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key - * @param \GetCandy\DataTypes\Price $value - * @param array $attributes - * + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key + * @param \GetCandy\DataTypes\Price $value + * @param array $attributes * @return array */ public function set($model, $key, $value, $attributes) diff --git a/src/Base/Casts/TaxBreakdown.php b/src/Base/Casts/TaxBreakdown.php index 7b1db53f..a24ddb84 100644 --- a/src/Base/Casts/TaxBreakdown.php +++ b/src/Base/Casts/TaxBreakdown.php @@ -11,11 +11,10 @@ class TaxBreakdown implements CastsAttributes /** * Cast the given value. * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key - * @param mixed $value - * @param array $attributes - * + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key + * @param mixed $value + * @param array $attributes * @return \Illuminate\Support\Collection */ public function get($model, $key, $value, $attributes) @@ -34,11 +33,10 @@ public function get($model, $key, $value, $attributes) /** * Prepare the given value for storage. * - * @param \Illuminate\Database\Eloquent\Model $model - * @param string $key - * @param \GetCandy\DataTypes\Price $value - * @param array $attributes - * + * @param \Illuminate\Database\Eloquent\Model $model + * @param string $key + * @param \GetCandy\DataTypes\Price $value + * @param array $attributes * @return array */ public function set($model, $key, $value, $attributes) diff --git a/src/Base/FieldType.php b/src/Base/FieldType.php index f9f5fc0d..31620e21 100644 --- a/src/Base/FieldType.php +++ b/src/Base/FieldType.php @@ -14,8 +14,7 @@ public function getValue(); /** * Set the value for the field type. * - * @param mixed $value - * + * @param mixed $value * @return void */ public function setValue($value); diff --git a/src/Base/FieldTypeManifest.php b/src/Base/FieldTypeManifest.php index e00b1263..2303118f 100644 --- a/src/Base/FieldTypeManifest.php +++ b/src/Base/FieldTypeManifest.php @@ -35,17 +35,16 @@ public function __construct() /** * Add a FieldType into GetCandy. * - * @param string $classname - * + * @param string $classname * @return void */ public function add($classname) { - if (!class_exists($classname)) { + if (! class_exists($classname)) { throw new FieldTypeMissingException($classname); } - if (!(app()->make($classname) instanceof FieldType)) { + if (! (app()->make($classname) instanceof FieldType)) { throw new InvalidFieldTypeException($classname); } diff --git a/src/Base/FieldTypeManifestInterface.php b/src/Base/FieldTypeManifestInterface.php index 6ad4e317..d6fd788e 100644 --- a/src/Base/FieldTypeManifestInterface.php +++ b/src/Base/FieldTypeManifestInterface.php @@ -9,8 +9,7 @@ interface FieldTypeManifestInterface /** * Add an attribute type. * - * @param string $classname - * + * @param string $classname * @return void */ public function add($classname); diff --git a/src/Base/OrderReferenceGenerator.php b/src/Base/OrderReferenceGenerator.php index 07fbe74a..79c8b434 100644 --- a/src/Base/OrderReferenceGenerator.php +++ b/src/Base/OrderReferenceGenerator.php @@ -35,7 +35,7 @@ public function generate(Order $order): string ->where('id', '!=', $order->id) ->first(); - if (!$latest || !$latest->reference) { + if (! $latest || ! $latest->reference) { $increment = 1; } else { $segments = explode('-', $latest->reference); @@ -53,8 +53,7 @@ public function generate(Order $order): string /** * Override the current method of generating a reference. * - * @param Closure $callback - * + * @param Closure $callback * @return self */ public function override(Closure $callback) diff --git a/src/Base/OrderReferenceGeneratorInterface.php b/src/Base/OrderReferenceGeneratorInterface.php index 2b9cdc5c..218a820f 100644 --- a/src/Base/OrderReferenceGeneratorInterface.php +++ b/src/Base/OrderReferenceGeneratorInterface.php @@ -9,8 +9,7 @@ interface OrderReferenceGeneratorInterface /** * Generate a reference for the order. * - * @param \GetCandy\Models\Order $order - * + * @param \GetCandy\Models\Order $order * @return string */ public function generate(Order $order): string; diff --git a/src/Base/PricingManagerInterface.php b/src/Base/PricingManagerInterface.php index a997f434..a119363e 100644 --- a/src/Base/PricingManagerInterface.php +++ b/src/Base/PricingManagerInterface.php @@ -12,8 +12,7 @@ interface PricingManagerInterface /** * Set the user property. * - * @param \Illuminate\Contracts\Auth\Authenticatable $user - * + * @param \Illuminate\Contracts\Auth\Authenticatable $user * @return self */ public function user(Authenticatable $user); @@ -21,8 +20,7 @@ public function user(Authenticatable $user); /** * Set the currency property. * - * @param \GetCandy\Models\Currency $currency - * + * @param \GetCandy\Models\Currency $currency * @return self */ public function currency(Currency $currency); @@ -30,8 +28,7 @@ public function currency(Currency $currency); /** * Set the quantity property. * - * @param int $qty - * + * @param int $qty * @return self */ public function qty(int $qty); @@ -39,8 +36,7 @@ public function qty(int $qty); /** * Set the customer groups. * - * @param Collection $customerGroups - * + * @param Collection $customerGroups * @return self */ public function customerGroups(Collection $customerGroups); @@ -48,8 +44,7 @@ public function customerGroups(Collection $customerGroups); /** * Set the customer group. * - * @param CustomerGroup $customerGroup - * + * @param CustomerGroup $customerGroup * @return self */ public function customerGroup(CustomerGroup $customerGroup); @@ -57,8 +52,7 @@ public function customerGroup(CustomerGroup $customerGroup); /** * Get the price for a purchasable. * - * @param Purchasable $purchasable - * + * @param Purchasable $purchasable * @return \GetCandy\Base\DataTransferObjects\PricingResponse */ public function for(Purchasable $purchasable); diff --git a/src/Base/ShippingManifest.php b/src/Base/ShippingManifest.php index 4298604c..9bd3ff88 100644 --- a/src/Base/ShippingManifest.php +++ b/src/Base/ShippingManifest.php @@ -34,7 +34,7 @@ public function addOption(ShippingOption $option) }); // Does this option already exist? - if (!$exists) { + if (! $exists) { $this->options->push($option); } diff --git a/src/Base/ShippingManifestInterface.php b/src/Base/ShippingManifestInterface.php index fff14de2..c7dfcd15 100644 --- a/src/Base/ShippingManifestInterface.php +++ b/src/Base/ShippingManifestInterface.php @@ -11,8 +11,7 @@ interface ShippingManifestInterface /** * Add a shipping option to the manifest. * - * @param \GetCandy\DataTypes\ShippingOption $shippingOption - * + * @param \GetCandy\DataTypes\ShippingOption $shippingOption * @return self */ public function addOption(ShippingOption $shippingOption); @@ -20,8 +19,7 @@ public function addOption(ShippingOption $shippingOption); /** * Return available options for a given cart. * - * @param \GetCandy\Models\Cart $cart - * + * @param \GetCandy\Models\Cart $cart * @return \Illuminate\Support\Collection */ public function getOptions(Cart $cart): Collection; diff --git a/src/Base/ShippingModifiers.php b/src/Base/ShippingModifiers.php index 3c7966e1..b9769307 100644 --- a/src/Base/ShippingModifiers.php +++ b/src/Base/ShippingModifiers.php @@ -35,7 +35,6 @@ public function getModifiers() * Add a shipping modifier. * * @param $modifier Class reference to the modifier. - * * @return void */ public function add($modifier) diff --git a/src/Base/TaxDriver.php b/src/Base/TaxDriver.php index 8be211b9..d97ec8e6 100644 --- a/src/Base/TaxDriver.php +++ b/src/Base/TaxDriver.php @@ -9,8 +9,7 @@ interface TaxDriver /** * Set the shipping address. * - * @param \GetCandy\Base\Addressable|null $address - * + * @param \GetCandy\Base\Addressable|null $address * @return self */ public function setShippingAddress(Addressable $address = null); @@ -18,8 +17,7 @@ public function setShippingAddress(Addressable $address = null); /** * Set the currency. * - * @param \GetCandy\Models\Currency $currency - * + * @param \GetCandy\Models\Currency $currency * @return self */ public function setCurrency(Currency $currency); @@ -27,8 +25,7 @@ public function setCurrency(Currency $currency); /** * Set the billing address. * - * @param \GetCandy\Base\Addressable|null $address - * + * @param \GetCandy\Base\Addressable|null $address * @return self */ public function setBillingAddress(Addressable $address = null); @@ -36,8 +33,7 @@ public function setBillingAddress(Addressable $address = null); /** * Set the purchasable item. * - * @param \GetCandy\Base\Purchasable $purchasable - * + * @param \GetCandy\Base\Purchasable $purchasable * @return self */ public function setPurchasable(Purchasable $purchasable); @@ -45,7 +41,7 @@ public function setPurchasable(Purchasable $purchasable); /** * Return the tax breakdown from a given sub total. * - * @param int $subTotal + * @param int $subTotal */ public function getBreakdown($subTotal); } diff --git a/src/Base/Traits/CanScheduleAvailability.php b/src/Base/Traits/CanScheduleAvailability.php index 10c90662..40995d97 100644 --- a/src/Base/Traits/CanScheduleAvailability.php +++ b/src/Base/Traits/CanScheduleAvailability.php @@ -12,8 +12,7 @@ trait CanScheduleAvailability /** * Return whether or not the models provided are suitable for scheduling. * - * @param \Illuminate\Support\Collection $models - * + * @param \Illuminate\Support\Collection $models * @return void */ abstract protected function validateScheduling(Collection $models); @@ -21,12 +20,11 @@ abstract protected function validateScheduling(Collection $models); /** * Schedule models for a given relation. * - * @param \Illuminate\Database\Eloquent\Relations\Relation $relation - * @param mixed $models - * @param DateTime|null $starts - * @param DateTime|null $ends - * @param array $pivotData - * + * @param \Illuminate\Database\Eloquent\Relations\Relation $relation + * @param mixed $models + * @param DateTime|null $starts + * @param DateTime|null $ends + * @param array $pivotData * @return void */ protected function schedule( @@ -39,13 +37,13 @@ protected function schedule( // Convert to collection if it's an array $models = is_array($models) ? collect($models) : $models; - if (!is_iterable($models)) { + if (! is_iterable($models)) { $models = collect([$models]); } $error = $this->validateScheduling($models); - if (!is_null($error)) { + if (! is_null($error)) { throw new SchedulingException($error); } @@ -63,10 +61,9 @@ protected function schedule( /** * Unschedule models for a relation. * - * @param Relation $relation - * @param mixed $models - * @param array $pivotData - * + * @param Relation $relation + * @param mixed $models + * @param array $pivotData * @return void */ protected function unschedule(Relation $relation, $models, array $pivotData = []) @@ -74,13 +71,13 @@ protected function unschedule(Relation $relation, $models, array $pivotData = [] // Convert to collection if it's an array $models = is_array($models) ? collect($models) : $models; - if (!is_iterable($models)) { + if (! is_iterable($models)) { $models = collect([$models]); } $error = $this->validateScheduling($models); - if (!is_null($error)) { + if (! is_null($error)) { throw new SchedulingException($error); } @@ -96,9 +93,8 @@ protected function unschedule(Relation $relation, $models, array $pivotData = [] /** * Returns the data for the sync update. * - * @param \Illuminate\Support\Collection $models - * @param array|null $pivotData - * + * @param \Illuminate\Support\Collection $models + * @param array|null $pivotData * @return \Illuminate\Support\Collection */ private function getScheduleMapping($models, array $pivotData = null) diff --git a/src/Base/Traits/HasCustomerGroups.php b/src/Base/Traits/HasCustomerGroups.php index da4a4488..a8eb2605 100644 --- a/src/Base/Traits/HasCustomerGroups.php +++ b/src/Base/Traits/HasCustomerGroups.php @@ -21,11 +21,10 @@ abstract public function customerGroups(): Relation; /** * Schedule models against customer groups. * - * @param mixed $models - * @param DateTime|null $starts - * @param DateTime|null $ends - * @param array $pivotData - * + * @param mixed $models + * @param DateTime|null $starts + * @param DateTime|null $ends + * @param array $pivotData * @return void */ public function scheduleCustomerGroup( @@ -46,9 +45,8 @@ public function scheduleCustomerGroup( /** * Unschedule models against a customer group. * - * @param mixed $models - * @param array $pivotData - * + * @param mixed $models + * @param array $pivotData * @return void */ public function unscheduleCustomerGroup( @@ -65,7 +63,7 @@ public function unscheduleCustomerGroup( protected function validateScheduling(Collection $models) { foreach ($models as $model) { - if (is_object($model) && !($model instanceof CustomerGroup)) { + if (is_object($model) && ! ($model instanceof CustomerGroup)) { return false; } } diff --git a/src/Base/Traits/HasDefaultRecord.php b/src/Base/Traits/HasDefaultRecord.php index 9a8ab8d1..83f8eafd 100644 --- a/src/Base/Traits/HasDefaultRecord.php +++ b/src/Base/Traits/HasDefaultRecord.php @@ -7,8 +7,7 @@ trait HasDefaultRecord /** * Return the default scope. * - * @param \Illuminate\Database\Eloquent\Builder $query - * + * @param \Illuminate\Database\Eloquent\Builder $query * @return void */ public function scopeDefault($query, $default = true) diff --git a/src/Base/Traits/HasTranslations.php b/src/Base/Traits/HasTranslations.php index f44183fa..78c04f25 100644 --- a/src/Base/Traits/HasTranslations.php +++ b/src/Base/Traits/HasTranslations.php @@ -10,9 +10,8 @@ trait HasTranslations /** * Translate a given attribute based on passed locale. * - * @param string $attribute - * @param string $locale - * + * @param string $attribute + * @param string $locale * @return string */ public function translate($attribute, $locale = null) @@ -23,7 +22,7 @@ public function translate($attribute, $locale = null) return $values; } - if (!$values) { + if (! $values) { return null; } @@ -39,29 +38,28 @@ public function translate($attribute, $locale = null) /** * Translate a value from attribute data. * - * @param string $attribute - * @param string $locale - * + * @param string $attribute + * @param string $locale * @return string */ public function translateAttribute($attribute, $locale = null) { $field = Arr::get($this->getAttribute('attribute_data'), $attribute); - if (!$field) { + if (! $field) { return null; } $translations = $field->getValue(); - if (!is_iterable($translations) || !$translations) { + if (! is_iterable($translations) || ! $translations) { return $translations; } $value = Arr::get($translations, $locale ?: app()->getLocale(), Arr::first($translations)); // We we don't have a value, we just return null as it may not have a value. - if (!$value) { + if (! $value) { return; } @@ -69,7 +67,7 @@ public function translateAttribute($attribute, $locale = null) * If we don't return a field type, then somethings up and it doesn't look like * this is translatable, in this case, just return what the fields value is. */ - if (!$value instanceof FieldType) { + if (! $value instanceof FieldType) { return $field->getValue(); } diff --git a/src/Console/Commands/Import/AddressData.php b/src/Console/Commands/Import/AddressData.php index 7594563b..8c97b84c 100644 --- a/src/Console/Commands/Import/AddressData.php +++ b/src/Console/Commands/Import/AddressData.php @@ -42,10 +42,10 @@ public function handle() ->object(); $newCountries = collect($countries)->filter(function ($country) use ($existing) { - return !$existing->contains($country->iso3); + return ! $existing->contains($country->iso3); }); - if (!$newCountries->count()) { + if (! $newCountries->count()) { $this->info('There are no new countries to import'); return Command::SUCCESS; diff --git a/src/Console/InstallGetCandy.php b/src/Console/InstallGetCandy.php index b2c530a3..70d077c2 100644 --- a/src/Console/InstallGetCandy.php +++ b/src/Console/InstallGetCandy.php @@ -48,7 +48,7 @@ public function handle(): void $this->info('Publishing configuration...'); - if (!$this->configExists('getcandy')) { + if (! $this->configExists('getcandy')) { $this->publishConfiguration(); } else { if ($this->shouldOverwriteConfig()) { @@ -61,12 +61,12 @@ public function handle(): void $this->info('Publishing hub assets'); - if (!Country::count()) { + if (! Country::count()) { $this->info('Importing countries'); $this->call('getcandy:import:address-data'); } - if (!Channel::whereDefault(true)->exists()) { + if (! Channel::whereDefault(true)->exists()) { $this->info('Setting up default channel'); Channel::create([ @@ -77,7 +77,7 @@ public function handle(): void ]); } - if (!Staff::whereAdmin(true)->exists()) { + if (! Staff::whereAdmin(true)->exists()) { $this->info('Create an admin user'); $firstname = $this->ask('Whats your first name?'); @@ -94,7 +94,7 @@ public function handle(): void ]); } - if (!Language::count()) { + if (! Language::count()) { $this->info('Adding default language'); Language::create([ @@ -104,7 +104,7 @@ public function handle(): void ]); } - if (!Currency::whereDefault(true)->exists()) { + if (! Currency::whereDefault(true)->exists()) { $this->info('Adding a default currency (USD)'); Currency::create([ @@ -120,7 +120,7 @@ public function handle(): void ]); } - if (!CustomerGroup::whereDefault(true)->exists()) { + if (! CustomerGroup::whereDefault(true)->exists()) { $this->info('Adding a default customer group.'); CustomerGroup::create([ @@ -130,7 +130,7 @@ public function handle(): void ]); } - if (!CollectionGroup::count()) { + if (! CollectionGroup::count()) { $this->info('Adding an initial collection group'); CollectionGroup::create([ @@ -139,7 +139,7 @@ public function handle(): void ]); } - if (!TaxClass::count()) { + if (! TaxClass::count()) { $this->info('Adding a default tax class.'); TaxClass::create([ @@ -148,7 +148,7 @@ public function handle(): void ]); } - if (!Attribute::count()) { + if (! Attribute::count()) { $this->info('Setting up initial attributes'); $group = AttributeGroup::create([ @@ -242,7 +242,7 @@ public function handle(): void ]); } - if (!ProductType::count()) { + if (! ProductType::count()) { $this->info('Adding a product type.'); $type = ProductType::create([ @@ -269,17 +269,16 @@ public function handle(): void /** * Checks if config exists given a filename. * - * @param string $fileName - * + * @param string $fileName * @return bool */ private function configExists($fileName): bool { - if (!File::isDirectory(config_path($fileName))) { + if (! File::isDirectory(config_path($fileName))) { return false; } - return !empty(File::allFiles(config_path($fileName))); + return ! empty(File::allFiles(config_path($fileName))); } /** @@ -298,8 +297,7 @@ private function shouldOverwriteConfig(): bool /** * Publishes configuration for the Service Provider. * - * @param bool $forcePublish - * + * @param bool $forcePublish * @return void */ private function publishConfiguration($forcePublish = false): void diff --git a/src/DataTypes/Price.php b/src/DataTypes/Price.php index 118739af..3474c60e 100644 --- a/src/DataTypes/Price.php +++ b/src/DataTypes/Price.php @@ -10,16 +10,16 @@ class Price /** * Initialise the Price datatype. * - * @param mixed $value - * @param Currency $currency - * @param int $unitQty + * @param mixed $value + * @param Currency $currency + * @param int $unitQty */ public function __construct( public $value, public Currency $currency, public int $unitQty = 1 ) { - if (!is_int($value)) { + if (! is_int($value)) { throw new InvalidDataTypeValueException( 'Value was "'.(gettype($value)).'" expected "int"' ); @@ -32,8 +32,7 @@ public function __construct( /** * Getter for methods/properties. * - * @param string $name - * + * @param string $name * @return void */ public function __get($name) diff --git a/src/FieldTypes/Dropdown.php b/src/FieldTypes/Dropdown.php index 318a2ddd..0b6b5300 100644 --- a/src/FieldTypes/Dropdown.php +++ b/src/FieldTypes/Dropdown.php @@ -15,7 +15,7 @@ class Dropdown implements FieldType /** * Create a new instance of List field type. * - * @param string|int $value + * @param string|int $value */ public function __construct($value = '') { @@ -35,11 +35,11 @@ public function getValue() /** * Set the value of this field. * - * @param string|int $value + * @param string|int $value */ public function setValue($value) { - if ($value && !is_string($value)) { + if ($value && ! is_string($value)) { throw new FieldTypeException(self::class.' value must be a string.'); } diff --git a/src/FieldTypes/ListField.php b/src/FieldTypes/ListField.php index d2e5641a..cddf9cbc 100644 --- a/src/FieldTypes/ListField.php +++ b/src/FieldTypes/ListField.php @@ -15,7 +15,7 @@ class ListField implements FieldType /** * Create a new instance of List field type. * - * @param int|float $value + * @param int|float $value */ public function __construct($value = []) { @@ -35,11 +35,11 @@ public function getValue() /** * Set the value of this field. * - * @param int|float $value + * @param int|float $value */ public function setValue($value) { - if (!is_array($value)) { + if (! is_array($value)) { throw new FieldTypeException(self::class.' value must be an array.'); } diff --git a/src/FieldTypes/Number.php b/src/FieldTypes/Number.php index b6737ec3..0483de85 100644 --- a/src/FieldTypes/Number.php +++ b/src/FieldTypes/Number.php @@ -15,7 +15,7 @@ class Number implements FieldType /** * Create a new instance of Number field type. * - * @param int|float $value + * @param int|float $value */ public function __construct($value = 0) { @@ -35,11 +35,11 @@ public function getValue() /** * Set the value of this field. * - * @param int|float $value + * @param int|float $value */ public function setValue($value) { - if (!is_numeric($value)) { + if (! is_numeric($value)) { throw new FieldTypeException(self::class.' value must be numeric.'); } diff --git a/src/FieldTypes/Text.php b/src/FieldTypes/Text.php index f307e1b3..306b3b54 100644 --- a/src/FieldTypes/Text.php +++ b/src/FieldTypes/Text.php @@ -26,7 +26,7 @@ public function jsonSerialize() /** * Create a new instance of Text field type. * - * @param string $value + * @param string $value */ public function __construct($value = '') { @@ -56,11 +56,11 @@ public function getValue() /** * Set the value of this field. * - * @param string $value + * @param string $value */ public function setValue($value) { - if ($value && (!is_string($value) && !is_numeric($value) && !is_bool($value))) { + if ($value && (! is_string($value) && ! is_numeric($value) && ! is_bool($value))) { throw new FieldTypeException(self::class.' value must be a string.'); } diff --git a/src/FieldTypes/Toggle.php b/src/FieldTypes/Toggle.php index 9932feeb..addc955d 100644 --- a/src/FieldTypes/Toggle.php +++ b/src/FieldTypes/Toggle.php @@ -26,7 +26,7 @@ public function jsonSerialize() /** * Create a new instance of Text field type. * - * @param string $value + * @param string $value */ public function __construct($value = '') { @@ -56,7 +56,7 @@ public function getValue() /** * Set the value of this field. * - * @param string $value + * @param string $value */ public function setValue($value) { diff --git a/src/FieldTypes/TranslatedText.php b/src/FieldTypes/TranslatedText.php index df4c2a08..d06f390d 100644 --- a/src/FieldTypes/TranslatedText.php +++ b/src/FieldTypes/TranslatedText.php @@ -17,7 +17,7 @@ class TranslatedText implements FieldType, JsonSerializable /** * Create a new instance of TranslatedText field type. * - * @param \Illuminate\Database\Eloquent\Collection $value + * @param \Illuminate\Database\Eloquent\Collection $value */ public function __construct($value = null) { @@ -51,7 +51,7 @@ public function getValue() /** * Set the value of this field. * - * @param \Illuminate\Database\Eloquent\Collection $value + * @param \Illuminate\Database\Eloquent\Collection $value */ public function setValue($value) { @@ -59,7 +59,7 @@ public function setValue($value) $value = collect($value); } - if (!$value instanceof \Illuminate\Support\Collection) { + if (! $value instanceof \Illuminate\Support\Collection) { throw new FieldTypeException(self::class.' value must be a collection.'); } diff --git a/src/GetCandyServiceProvider.php b/src/GetCandyServiceProvider.php index 30ad55d8..1f079d50 100644 --- a/src/GetCandyServiceProvider.php +++ b/src/GetCandyServiceProvider.php @@ -99,7 +99,7 @@ public function boot(): void $this->registerAddonManifest(); $this->registerBlueprintMacros(); - if (!$this->app->environment('testing')) { + if (! $this->app->environment('testing')) { $this->registerStateListeners(); } diff --git a/src/Jobs/Collections/RebuildCollectionTree.php b/src/Jobs/Collections/RebuildCollectionTree.php index d258866f..fcdae66d 100644 --- a/src/Jobs/Collections/RebuildCollectionTree.php +++ b/src/Jobs/Collections/RebuildCollectionTree.php @@ -43,9 +43,9 @@ class RebuildCollectionTree implements ShouldQueue /** * Create a new job instance. * - * @param array $newTree - * @param array $currentTree - * @param \GetCandy\Models\Collection|null $parent + * @param array $newTree + * @param array $currentTree + * @param \GetCandy\Models\Collection|null $parent */ public function __construct(array $newTree, array $currentTree, Collection $parent = null) { diff --git a/src/Jobs/Collections/UpdateProductPositions.php b/src/Jobs/Collections/UpdateProductPositions.php index c40245fb..f8d2c19c 100644 --- a/src/Jobs/Collections/UpdateProductPositions.php +++ b/src/Jobs/Collections/UpdateProductPositions.php @@ -30,7 +30,7 @@ class UpdateProductPositions implements ShouldQueue /** * Create a new job instance. * - * @param Collection $collection + * @param Collection $collection */ public function __construct(Collection $collection) { diff --git a/src/Jobs/Products/Associations/Associate.php b/src/Jobs/Products/Associations/Associate.php index 1b0772f9..3e7f8a75 100644 --- a/src/Jobs/Products/Associations/Associate.php +++ b/src/Jobs/Products/Associations/Associate.php @@ -44,9 +44,9 @@ class Associate implements ShouldQueue /** * Create a new job instance. * - * @param \GetCandy\Models\Product $product - * @param mixed $targets - * @param string $type + * @param \GetCandy\Models\Product $product + * @param mixed $targets + * @param string $type */ public function __construct(Product $product, $targets, $type = null) { @@ -54,7 +54,7 @@ public function __construct(Product $product, $targets, $type = null) $targets = collect($targets); } - if (!$targets instanceof Collection) { + if (! $targets instanceof Collection) { $targets = collect([$targets]); } diff --git a/src/Jobs/Products/Associations/Dissociate.php b/src/Jobs/Products/Associations/Dissociate.php index 71bc5027..d4d9be7d 100644 --- a/src/Jobs/Products/Associations/Dissociate.php +++ b/src/Jobs/Products/Associations/Dissociate.php @@ -44,9 +44,9 @@ class Dissociate implements ShouldQueue /** * Create a new job instance. * - * @param \GetCandy\Models\Product $product - * @param mixed $targets - * @param string $type + * @param \GetCandy\Models\Product $product + * @param mixed $targets + * @param string $type */ public function __construct(Product $product, $targets, $type = null) { @@ -54,7 +54,7 @@ public function __construct(Product $product, $targets, $type = null) $targets = collect($targets); } - if (!$targets instanceof Collection) { + if (! $targets instanceof Collection) { $targets = collect([$targets]); } diff --git a/src/Jobs/SyncTags.php b/src/Jobs/SyncTags.php index 3d216313..994bee9e 100644 --- a/src/Jobs/SyncTags.php +++ b/src/Jobs/SyncTags.php @@ -39,9 +39,8 @@ class SyncTags implements ShouldQueue /** * Create a new job instance. * - * @param \Illuminate\Database\Eloquent\Model $model - * @param \Illuminate\Support\Collection $tags - * + * @param \Illuminate\Database\Eloquent\Model $model + * @param \Illuminate\Support\Collection $tags * @return void */ public function __construct(Model $model, Collection $tags) diff --git a/src/Listeners/CartSessionAuthListener.php b/src/Listeners/CartSessionAuthListener.php index 508817b3..cc00234d 100644 --- a/src/Listeners/CartSessionAuthListener.php +++ b/src/Listeners/CartSessionAuthListener.php @@ -22,15 +22,14 @@ public function __construct() /** * Handle the login event. * - * @param \Illuminate\Auth\Events\Login $event - * + * @param \Illuminate\Auth\Events\Login $event * @return void */ public function login(Login $event) { $currentCart = CartSession::current(); - if ($currentCart && !$currentCart->user_id) { + if ($currentCart && ! $currentCart->user_id) { CartSession::associate( $currentCart, $event->user, @@ -38,7 +37,7 @@ public function login(Login $event) ); } - if (!$currentCart) { + if (! $currentCart) { // Does this user have a cart? $userCart = Cart::whereUserId($event->user->getKey())->latest()->first(); @@ -51,8 +50,7 @@ public function login(Login $event) /** * Handle the logout event. * - * @param \Illuminate\Auth\Events\Logout $event - * + * @param \Illuminate\Auth\Events\Logout $event * @return void */ public function logout(Logout $event) diff --git a/src/Managers/CartLineManager.php b/src/Managers/CartLineManager.php index 2d2851ff..5cfad39b 100644 --- a/src/Managers/CartLineManager.php +++ b/src/Managers/CartLineManager.php @@ -13,7 +13,7 @@ class CartLineManager /** * Initialize the cart manager. * - * @param \GetCandy\Models\CartLine $cartLine + * @param \GetCandy\Models\CartLine $cartLine */ public function __construct( protected CartLine $cartLine diff --git a/src/Managers/CartManager.php b/src/Managers/CartManager.php index 48a2b3c4..f1289aaf 100644 --- a/src/Managers/CartManager.php +++ b/src/Managers/CartManager.php @@ -47,7 +47,7 @@ class CartManager /** * Initialize the cart manager. * - * @param Cart $cart + * @param Cart $cart */ public function __construct( protected Cart $cart, @@ -144,10 +144,9 @@ public function getCart(): Cart /** * Add a line to the cart. * - * @param Purchasable $purchasable - * @param int $quantity - * @param array $meta - * + * @param Purchasable $purchasable + * @param int $quantity + * @param array $meta * @return bool */ public function add(Purchasable $purchasable, int $quantity = 1, $meta = []) @@ -192,11 +191,10 @@ public function add(Purchasable $purchasable, int $quantity = 1, $meta = []) /** * Remove a cart line from the cart. * - * @param int|string $cartLineId + * @param int|string $cartLineId + * @return \GetCandy\Models\Cart * * @throws \GetCandy\Exceptions\CartLineIdMismatchException - * - * @return \GetCandy\Models\Cart */ public function removeLine($cartLineId) { @@ -204,7 +202,7 @@ public function removeLine($cartLineId) // belong to this cart, throw an exception. $line = $this->cart->lines()->whereId($cartLineId)->first(); - if (!$line) { + if (! $line) { throw new CartLineIdMismatchException( __('getcandy::exceptions.cart_line_id_mismatch') ); @@ -218,8 +216,7 @@ public function removeLine($cartLineId) /** * Update cart lines. * - * @param Collection $lines - * + * @param Collection $lines * @return \GetCandy\Models\Cart */ public function updateLines(Collection $lines) @@ -240,10 +237,9 @@ public function updateLines(Collection $lines) /** * Update a cart line. * - * @param string|int $id - * @param int $quantity - * @param array|null $meta - * + * @param string|int $id + * @param int $quantity + * @param array|null $meta * @return void */ public function updateLine($id, int $quantity, $meta = null) @@ -269,9 +265,8 @@ public function updateLine($id, int $quantity, $meta = null) /** * Associate a user to the cart. * - * @param User $user - * @param string $policy - * + * @param User $user + * @param string $policy * @return \GetCandy\Models\Cart */ public function associate(User $user, $policy = 'merge') @@ -302,8 +297,7 @@ public function associate(User $user, $policy = 'merge') /** * Set the shipping address. * - * @param \GetCandy\Base\Addressable|array $address - * + * @param \GetCandy\Base\Addressable|array $address * @return \GetCandy\Models\Cart */ public function setShippingAddress(array|Addressable $address) @@ -318,8 +312,7 @@ public function setShippingAddress(array|Addressable $address) /** * Set the billing address. * - * @param array|Addressable $address - * + * @param array|Addressable $address * @return self */ public function setBillingAddress(array|Addressable $address) @@ -334,15 +327,14 @@ public function setBillingAddress(array|Addressable $address) /** * Set the shipping option to the shipping address. * - * @param ShippingOption $option + * @param ShippingOption $option + * @return self * * @throws \GetCandy\Exceptions\Carts\ShippingAddressMissingException - * - * @return self */ public function setShippingOption(ShippingOption $option) { - if (!$this->cart->shippingAddress) { + if (! $this->cart->shippingAddress) { throw new ShippingAddressMissingException(); } $this->cart->shippingAddress->shippingOption = $option; @@ -358,7 +350,7 @@ public function setShippingOption(ShippingOption $option) public function getShippingOption() { - if (!$this->cart->shippingAddress) { + if (! $this->cart->shippingAddress) { return null; } @@ -405,9 +397,8 @@ public function isShippable() /** * Add an address to the. * - * @param array|Addressable $address + * @param array|Addressable $address * @param [type] $type - * * @return void */ private function addAddress(array|Addressable $address, $type) diff --git a/src/Managers/CartSessionManager.php b/src/Managers/CartSessionManager.php index 8f20fc4f..b22d545f 100644 --- a/src/Managers/CartSessionManager.php +++ b/src/Managers/CartSessionManager.php @@ -48,7 +48,7 @@ public function forget() */ public function manager() { - if (!$this->cart) { + if (! $this->cart) { $this->fetchOrCreate(create:true); } @@ -81,8 +81,7 @@ public function use(Cart $cart) /** * Fetches a cart and optionally creates one if it doesn't exist. * - * @param bool $create - * + * @param bool $create * @return \GetCandy\Models\Cart|null */ private function fetchOrCreate($create = false) @@ -91,7 +90,7 @@ private function fetchOrCreate($create = false) $this->getSessionKey() ); - if (!$cartId) { + if (! $cartId) { return $create ? $this->cart = $this->createNewCart() : null; } @@ -99,8 +98,8 @@ private function fetchOrCreate($create = false) config('getcandy.cart.eager_load', []) )->find($cartId); - if (!$this->cart) { - if (!$create) { + if (! $this->cart) { + if (! $create) { return null; } diff --git a/src/Managers/PricingManager.php b/src/Managers/PricingManager.php index ca4678af..0a7bd63f 100644 --- a/src/Managers/PricingManager.php +++ b/src/Managers/PricingManager.php @@ -51,8 +51,7 @@ class PricingManager implements PricingManagerInterface /** * Set the user property. * - * @param \Illuminate\Contracts\Auth\Authenticatable $user - * + * @param \Illuminate\Contracts\Auth\Authenticatable $user * @return self */ public function user(Authenticatable $user) @@ -65,8 +64,7 @@ public function user(Authenticatable $user) /** * Set the currency property. * - * @param \GetCandy\Models\Currency $currency - * + * @param \GetCandy\Models\Currency $currency * @return self */ public function currency(Currency $currency) @@ -79,8 +77,7 @@ public function currency(Currency $currency) /** * Set the quantity property. * - * @param int $qty - * + * @param int $qty * @return self */ public function qty(int $qty) @@ -93,8 +90,7 @@ public function qty(int $qty) /** * Set the customer groups. * - * @param Collection $customerGroups - * + * @param Collection $customerGroups * @return self */ public function customerGroups(Collection $customerGroups) @@ -107,8 +103,7 @@ public function customerGroups(Collection $customerGroups) /** * Set the customer group. * - * @param CustomerGroup $customerGroup - * + * @param CustomerGroup $customerGroup * @return self */ public function customerGroup(CustomerGroup $customerGroup) @@ -123,17 +118,16 @@ public function customerGroup(CustomerGroup $customerGroup) /** * Get the price for a purchasable. * - * @param Purchasable $purchasable - * + * @param Purchasable $purchasable * @return \GetCandy\Base\DataTransferObjects\PricingResponse */ public function for(Purchasable $purchasable) { - if (!$this->currency) { + if (! $this->currency) { $this->currency = Currency::getDefault(); } - if (!$this->customerGroups || !$this->customerGroups->count()) { + if (! $this->customerGroups || ! $this->customerGroups->count()) { $this->customerGroups = collect( CustomerGroup::getDefault() ); @@ -153,19 +147,19 @@ public function for(Purchasable $purchasable) return $price->currency_id == $this->currency->id; }); - if (!$currencyPrices->count()) { + if (! $currencyPrices->count()) { throw new MissingCurrencyPriceException(); } $prices = $currencyPrices->filter(function ($price) { // Only fetch prices which have no customer group (available to all) or belong to the customer groups // that we are trying to check against. - return !$price->customer_group_id || + return ! $price->customer_group_id || $this->customerGroups->pluck('id')->contains($price->customer_group_id); })->sortBy('price'); // Get our base price - $basePrice = $prices->first(fn ($price) => $price->tier == 1 && !$price->customer_group_id); + $basePrice = $prices->first(fn ($price) => $price->tier == 1 && ! $price->customer_group_id); // To start, we'll set the matched price to the base price. $matched = $basePrice; @@ -187,8 +181,8 @@ public function for(Purchasable $purchasable) $response = new PricingResponse( matched: $matched, - base: $prices->first(fn ($price) => $price->tier == 1), - tiered: $prices->filter(fn ($price) => $price->tier > 1), + base: $prices->first(fn ($price) => $price->tier == 1), + tiered: $prices->filter(fn ($price) => $price->tier > 1), customerGroupPrices: $prices->filter(fn ($price) => (bool) $price->customer_group_id) ); diff --git a/src/Managers/TaxManager.php b/src/Managers/TaxManager.php index be5cb744..0113cf1e 100644 --- a/src/Managers/TaxManager.php +++ b/src/Managers/TaxManager.php @@ -15,8 +15,7 @@ public function createSystemDriver() /** * Build a tax provider instance. * - * @param string $provider - * + * @param string $provider * @return mixed */ public function buildProvider($provider) diff --git a/src/Models/Address.php b/src/Models/Address.php index 148ab45b..c90cbdb0 100644 --- a/src/Models/Address.php +++ b/src/Models/Address.php @@ -32,8 +32,7 @@ protected static function newFactory(): AddressFactory /** * Mutator for the meta attribute. * - * @param array|null $value - * + * @param array|null $value * @return void */ public function setMetaAttribute(array $value = null) @@ -46,8 +45,7 @@ public function setMetaAttribute(array $value = null) /** * Accessor for the meta attribute. * - * @param string $value - * + * @param string $value * @return array */ public function getMetaAttribute($value) diff --git a/src/Models/Attribute.php b/src/Models/Attribute.php index af3d8337..4fbba2cf 100644 --- a/src/Models/Attribute.php +++ b/src/Models/Attribute.php @@ -79,9 +79,8 @@ public function attributeGroup(): BelongsTo /** * Apply the system scope to the query builder. * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $type - * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param string $type * @return void */ public function scopeSystem(Builder $query, $type) diff --git a/src/Models/Channel.php b/src/Models/Channel.php index 8e7671df..ebf3d8d3 100644 --- a/src/Models/Channel.php +++ b/src/Models/Channel.php @@ -38,8 +38,7 @@ protected static function newFactory(): ChannelFactory /** * Mutator for formatting the handle to a slug. * - * @param string $val - * + * @param string $val * @return void */ public function setHandleAttribute($val) diff --git a/src/Models/Product.php b/src/Models/Product.php index cfa12eb5..bc26c2d2 100644 --- a/src/Models/Product.php +++ b/src/Models/Product.php @@ -132,9 +132,8 @@ public function associations() /** * Associate a product to another with a type. * - * @param mixed $product - * @param string $type - * + * @param mixed $product + * @param string $type * @return void */ public function associate($product, $type) @@ -145,9 +144,8 @@ public function associate($product, $type) /** * Dissociate a product to another with a type. * - * @param mixed $product - * @param string $type - * + * @param mixed $product + * @param string $type * @return void */ public function dissociate($product, $type = null) diff --git a/src/Models/ProductAssociation.php b/src/Models/ProductAssociation.php index e0b27d4a..762fdc4d 100644 --- a/src/Models/ProductAssociation.php +++ b/src/Models/ProductAssociation.php @@ -72,8 +72,7 @@ public function target() /** * Apply the cross sell scope. * - * @param \Illuminate\Database\Eloquent\Builder $query - * + * @param \Illuminate\Database\Eloquent\Builder $query * @return void */ public function scopeCrossSell(Builder $query) @@ -84,8 +83,7 @@ public function scopeCrossSell(Builder $query) /** * Apply the up sell scope. * - * @param \Illuminate\Database\Eloquent\Builder $query - * + * @param \Illuminate\Database\Eloquent\Builder $query * @return void */ public function scopeUpSell(Builder $query) @@ -96,8 +94,7 @@ public function scopeUpSell(Builder $query) /** * Apply the up alternate scope. * - * @param \Illuminate\Database\Eloquent\Builder $query - * + * @param \Illuminate\Database\Eloquent\Builder $query * @return void */ public function scopeAlternate(Builder $query) @@ -108,9 +105,8 @@ public function scopeAlternate(Builder $query) /** * Apply the type scope. * - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $type - * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param string $type * @return void */ public function scopeType(Builder $query, $type) diff --git a/src/Models/Url.php b/src/Models/Url.php index bb66c9e7..810e1012 100644 --- a/src/Models/Url.php +++ b/src/Models/Url.php @@ -60,8 +60,7 @@ public function language() /** * Return the query scope for default. * - * @param \Illuminate\Database\Query\Builder $query - * + * @param \Illuminate\Database\Query\Builder $query * @return \Illuminate\Database\Query\Builder */ public function scopeDefault($query) diff --git a/src/Observers/CartLineObserver.php b/src/Observers/CartLineObserver.php index e0eadae3..b427f631 100644 --- a/src/Observers/CartLineObserver.php +++ b/src/Observers/CartLineObserver.php @@ -11,13 +11,12 @@ class CartLineObserver /** * Handle the CartLine "creating" event. * - * @param \GetCandy\Models\CartLine $cartLine - * + * @param \GetCandy\Models\CartLine $cartLine * @return void */ public function creating(CartLine $cartLine) { - if (!$cartLine->purchasable instanceof Purchasable) { + if (! $cartLine->purchasable instanceof Purchasable) { throw new NonPurchasableItemException($cartLine->purchasable_type); } } @@ -25,13 +24,12 @@ public function creating(CartLine $cartLine) /** * Handle the CartLine "updated" event. * - * @param \GetCandy\Models\CartLine $cartLine - * + * @param \GetCandy\Models\CartLine $cartLine * @return void */ public function updating(CartLine $cartLine) { - if (!$cartLine->purchasable instanceof Purchasable) { + if (! $cartLine->purchasable instanceof Purchasable) { throw new NonPurchasableItemException($cartLine->purchasable_type); } } diff --git a/src/Observers/ChannelObserver.php b/src/Observers/ChannelObserver.php index 1a11b3c9..03eefb21 100644 --- a/src/Observers/ChannelObserver.php +++ b/src/Observers/ChannelObserver.php @@ -9,8 +9,7 @@ class ChannelObserver /** * Handle the User "created" event. * - * @param \GetCandy\Models\Channel $channel - * + * @param \GetCandy\Models\Channel $channel * @return void */ public function created(Channel $channel) @@ -21,8 +20,7 @@ public function created(Channel $channel) /** * Handle the User "updated" event. * - * @param \GetCandy\Models\Channel $channel - * + * @param \GetCandy\Models\Channel $channel * @return void */ public function updated(Channel $channel) @@ -33,8 +31,7 @@ public function updated(Channel $channel) /** * Handle the User "deleted" event. * - * @param \GetCandy\Models\Channel $channel - * + * @param \GetCandy\Models\Channel $channel * @return void */ public function deleted(Channel $channel) @@ -45,8 +42,7 @@ public function deleted(Channel $channel) /** * Handle the User "forceDeleted" event. * - * @param \GetCandy\Models\Channel $channel - * + * @param \GetCandy\Models\Channel $channel * @return void */ public function forceDeleted(Channel $channel) @@ -57,8 +53,7 @@ public function forceDeleted(Channel $channel) /** * Ensures that only one default channel exists. * - * @param Channel $savedChannel The channel that was just saved. - * + * @param Channel $savedChannel The channel that was just saved. * @return void */ protected function ensureOnlyOneDefault(Channel $savedChannel): void diff --git a/src/Observers/CollectionObserver.php b/src/Observers/CollectionObserver.php index 58344364..a5ecca9c 100644 --- a/src/Observers/CollectionObserver.php +++ b/src/Observers/CollectionObserver.php @@ -10,8 +10,7 @@ class CollectionObserver /** * Handle the Collection "updated" event. * - * @param \GetCandy\Models\Collection $collection - * + * @param \GetCandy\Models\Collection $collection * @return void */ public function updated(Collection $collection) diff --git a/src/Observers/CurrencyObserver.php b/src/Observers/CurrencyObserver.php index b02bb10e..06ff8f1e 100644 --- a/src/Observers/CurrencyObserver.php +++ b/src/Observers/CurrencyObserver.php @@ -9,8 +9,7 @@ class CurrencyObserver /** * Handle the Currency "created" event. * - * @param \GetCandy\Models\Currency $currency - * + * @param \GetCandy\Models\Currency $currency * @return void */ public function created(Currency $currency) @@ -21,8 +20,7 @@ public function created(Currency $currency) /** * Handle the Currency "updated" event. * - * @param \GetCandy\Models\Currency $currency - * + * @param \GetCandy\Models\Currency $currency * @return void */ public function updated(Currency $currency) @@ -33,8 +31,7 @@ public function updated(Currency $currency) /** * Handle the Currency "deleted" event. * - * @param \GetCandy\Models\Currency $currency - * + * @param \GetCandy\Models\Currency $currency * @return void */ public function deleted(Currency $currency) @@ -45,8 +42,7 @@ public function deleted(Currency $currency) /** * Handle the Currency "forceDeleted" event. * - * @param \GetCandy\Models\Currency $currency - * + * @param \GetCandy\Models\Currency $currency * @return void */ public function forceDeleted(Currency $currency) @@ -57,8 +53,7 @@ public function forceDeleted(Currency $currency) /** * Ensures that only one default currency exists. * - * @param \GetCandy\Models\Currency $savedCurrency The currency that was just saved. - * + * @param \GetCandy\Models\Currency $savedCurrency The currency that was just saved. * @return void */ protected function ensureOnlyOneDefault(Currency $savedCurrency): void diff --git a/src/Observers/LanguageObserver.php b/src/Observers/LanguageObserver.php index 2a3d75fc..abd09e81 100644 --- a/src/Observers/LanguageObserver.php +++ b/src/Observers/LanguageObserver.php @@ -9,8 +9,7 @@ class LanguageObserver /** * Handle the Language "created" event. * - * @param \GetCandy\Models\Language $language - * + * @param \GetCandy\Models\Language $language * @return void */ public function created(Language $language) @@ -21,8 +20,7 @@ public function created(Language $language) /** * Handle the Language "updated" event. * - * @param \GetCandy\Models\Language $language - * + * @param \GetCandy\Models\Language $language * @return void */ public function updated(Language $language) @@ -33,8 +31,7 @@ public function updated(Language $language) /** * Handle the Language "deleted" event. * - * @param \GetCandy\Models\Language $language - * + * @param \GetCandy\Models\Language $language * @return void */ public function deleted(Language $language) @@ -45,8 +42,7 @@ public function deleted(Language $language) /** * Handle the Language "forceDeleted" event. * - * @param \GetCandy\Models\Language $language - * + * @param \GetCandy\Models\Language $language * @return void */ public function forceDeleted(Language $language) @@ -57,8 +53,7 @@ public function forceDeleted(Language $language) /** * Ensures that only one default language exists. * - * @param \GetCandy\Models\Language $savedLanguage The language that was just saved. - * + * @param \GetCandy\Models\Language $savedLanguage The language that was just saved. * @return void */ protected function ensureOnlyOneDefault(Language $savedLanguage): void diff --git a/src/Observers/OrderLineObserver.php b/src/Observers/OrderLineObserver.php index e7e35b13..4a13ec97 100644 --- a/src/Observers/OrderLineObserver.php +++ b/src/Observers/OrderLineObserver.php @@ -11,13 +11,12 @@ class OrderLineObserver /** * Handle the OrderLine "creating" event. * - * @param \GetCandy\Models\OrderLine $orderLine - * + * @param \GetCandy\Models\OrderLine $orderLine * @return void */ public function creating(OrderLine $orderLine) { - if ($orderLine->type != 'shipping' && !$orderLine->purchasable instanceof Purchasable) { + if ($orderLine->type != 'shipping' && ! $orderLine->purchasable instanceof Purchasable) { throw new NonPurchasableItemException($orderLine->purchasable_type); } } @@ -25,13 +24,12 @@ public function creating(OrderLine $orderLine) /** * Handle the OrderLine "updated" event. * - * @param \GetCandy\Models\OrderLine $orderLine - * + * @param \GetCandy\Models\OrderLine $orderLine * @return void */ public function updating(OrderLine $orderLine) { - if (!$orderLine->purchasable instanceof Purchasable) { + if (! $orderLine->purchasable instanceof Purchasable) { throw new NonPurchasableItemException($orderLine->purchasable_type); } } diff --git a/src/Observers/UrlObserver.php b/src/Observers/UrlObserver.php index 34b89f3e..27b325be 100644 --- a/src/Observers/UrlObserver.php +++ b/src/Observers/UrlObserver.php @@ -9,8 +9,7 @@ class UrlObserver /** * Handle the Url "created" event. * - * @param \GetCandy\Models\Url $url - * + * @param \GetCandy\Models\Url $url * @return void */ public function created(Url $url) @@ -21,8 +20,7 @@ public function created(Url $url) /** * Handle the User "updated" event. * - * @param \GetCandy\Models\Url $url - * + * @param \GetCandy\Models\Url $url * @return void */ public function updated(Url $url) @@ -33,8 +31,7 @@ public function updated(Url $url) /** * Handle the Url "deleted" event. * - * @param \GetCandy\Models\Url $url - * + * @param \GetCandy\Models\Url $url * @return void */ public function deleted(Url $url) @@ -57,8 +54,7 @@ public function deleted(Url $url) /** * Ensures that only one default channel exists. * - * @param Url $savedUrl The url that was just saved. - * + * @param Url $savedUrl The url that was just saved. * @return void */ protected function ensureOnlyOneDefault(Url $savedUrl): void diff --git a/src/Rules/MaxDecimalPlaces.php b/src/Rules/MaxDecimalPlaces.php index b43c706e..c8328e34 100644 --- a/src/Rules/MaxDecimalPlaces.php +++ b/src/Rules/MaxDecimalPlaces.php @@ -16,9 +16,8 @@ public function __construct($maxDecimals = 2) /** * Determine if the validation rule passes. * - * @param string $attribute - * @param mixed $value - * + * @param string $attribute + * @param mixed $value * @return bool */ public function passes($attribute, $value) diff --git a/src/Utils/Arr.php b/src/Utils/Arr.php index b16d6f12..9e0dcd82 100644 --- a/src/Utils/Arr.php +++ b/src/Utils/Arr.php @@ -17,7 +17,7 @@ public static function permutate(array $setTuples, $isRecursiveStep = false) } foreach ($setTuples as $tuple) { - if (!is_array($tuple)) { + if (! is_array($tuple)) { throw new \InvalidArgumentException('The set builder requires a single array of one or more array sets.'); } } diff --git a/tests/Unit/Base/MacroableModelTest.php b/tests/Unit/Base/MacroableModelTest.php index bd5a930c..1642c832 100644 --- a/tests/Unit/Base/MacroableModelTest.php +++ b/tests/Unit/Base/MacroableModelTest.php @@ -33,7 +33,8 @@ public function can_register_a_new_macro() /** @test */ public function can_register_a_new_macro_and_be_invoked() { - $this->model::macro('newMethod', new class() { + $this->model::macro('newMethod', new class() + { public function __invoke() { return 'newValue'; diff --git a/tests/Unit/Managers/CartManagerTest.php b/tests/Unit/Managers/CartManagerTest.php index ec55ad4f..16e80e4e 100644 --- a/tests/Unit/Managers/CartManagerTest.php +++ b/tests/Unit/Managers/CartManagerTest.php @@ -292,20 +292,20 @@ public function can_update_cart_line_when_purchasable_exists() $cart->getManager()->add($purchasable, 1, null); - $this->assertDatabaseHas((new CartLine())->getTable(), [ + $this->assertDatabaseHas((new CartLine)->getTable(), [ 'purchasable_id' => $purchasable->id, - 'quantity' => 1, - 'meta' => null, + 'quantity' => 1, + 'meta' => null, ]); $this->assertCount(1, $cart->refresh()->lines); $cart->getManager()->add($purchasable, 1, null); - $this->assertDatabaseHas((new CartLine())->getTable(), [ + $this->assertDatabaseHas((new CartLine)->getTable(), [ 'purchasable_id' => $purchasable->id, - 'quantity' => 2, - 'meta' => null, + 'quantity' => 2, + 'meta' => null, ]); } @@ -320,59 +320,59 @@ public function can_update_cart_line_when_purchasable_exists_with_meta() $cart->getManager()->add($purchasable, 1, []); - $this->assertDatabaseHas((new CartLine())->getTable(), [ + $this->assertDatabaseHas((new CartLine)->getTable(), [ 'purchasable_id' => $purchasable->id, - 'quantity' => 1, - 'meta' => '[]', + 'quantity' => 1, + 'meta' => '[]', ]); - $this->assertDatabaseCount((new CartLine())->getTable(), 1); + $this->assertDatabaseCount((new CartLine)->getTable(), 1); $cart->getManager()->add($purchasable, 1); - $this->assertDatabaseHas((new CartLine())->getTable(), [ + $this->assertDatabaseHas((new CartLine)->getTable(), [ 'purchasable_id' => $purchasable->id, - 'quantity' => 2, - 'meta' => '[]', + 'quantity' => 2, + 'meta' => '[]', ]); $cart->getManager()->add($purchasable, 1, []); - $this->assertDatabaseHas((new CartLine())->getTable(), [ + $this->assertDatabaseHas((new CartLine)->getTable(), [ 'purchasable_id' => $purchasable->id, - 'quantity' => 3, - 'meta' => '[]', + 'quantity' => 3, + 'meta' => '[]', ]); - $this->assertDatabaseCount((new CartLine())->getTable(), 1); + $this->assertDatabaseCount((new CartLine)->getTable(), 1); - $this->assertDatabaseCount((new CartLine())->getTable(), 1); + $this->assertDatabaseCount((new CartLine)->getTable(), 1); $cart->getManager()->add($purchasable, 1, null); - $this->assertDatabaseHas((new CartLine())->getTable(), [ + $this->assertDatabaseHas((new CartLine)->getTable(), [ 'purchasable_id' => $purchasable->id, - 'quantity' => 4, - 'meta' => '[]', + 'quantity' => 4, + 'meta' => '[]', ]); - $this->assertDatabaseCount((new CartLine())->getTable(), 1); + $this->assertDatabaseCount((new CartLine)->getTable(), 1); $cart->getManager()->add($purchasable, 1, ['foo' => 'bar']); - $this->assertDatabaseHas((new CartLine())->getTable(), [ + $this->assertDatabaseHas((new CartLine)->getTable(), [ 'purchasable_id' => $purchasable->id, - 'quantity' => 4, - 'meta' => '[]', + 'quantity' => 4, + 'meta' => '[]', ]); - $this->assertDatabaseHas((new CartLine())->getTable(), [ + $this->assertDatabaseHas((new CartLine)->getTable(), [ 'purchasable_id' => $purchasable->id, - 'quantity' => 1, - 'meta' => '{"foo":"bar"}', + 'quantity' => 1, + 'meta' => '{"foo":"bar"}', ]); - $this->assertDatabaseCount((new CartLine())->getTable(), 2); + $this->assertDatabaseCount((new CartLine)->getTable(), 2); } /** @test */ diff --git a/tests/Unit/Models/ProductOptionTest.php b/tests/Unit/Models/ProductOptionTest.php index 97eacc21..3c860b09 100644 --- a/tests/Unit/Models/ProductOptionTest.php +++ b/tests/Unit/Models/ProductOptionTest.php @@ -20,6 +20,6 @@ public function takes_scout_prefix_into_account() { $expected = config('scout.prefix').'product_options_en'; - $this->assertEquals($expected, (new ProductOption())->searchableAs()); + $this->assertEquals($expected, (new ProductOption)->searchableAs()); } } diff --git a/tests/Unit/Models/ProductTest.php b/tests/Unit/Models/ProductTest.php index 1b068f47..5acd0912 100644 --- a/tests/Unit/Models/ProductTest.php +++ b/tests/Unit/Models/ProductTest.php @@ -48,7 +48,7 @@ public function takes_scout_prefix_into_account() { $expected = config('scout.prefix').'products_en'; - $this->assertEquals($expected, (new Product())->searchableAs()); + $this->assertEquals($expected, (new Product)->searchableAs()); } /** @test */