From c0ad168585630e435489c9faaf8f092123bee397 Mon Sep 17 00:00:00 2001 From: Glenn Jacobs Date: Mon, 4 Apr 2022 13:07:06 +0000 Subject: [PATCH] Apply fixes from StyleCI --- config/payments.php | 2 +- database/factories/OrderFactory.php | 4 +- database/factories/OrderLineFactory.php | 4 +- .../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 | 7 +- src/Actions/Carts/CreateOrder.php | 21 ++--- 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/DataTransferObjects/TaxBreakdown.php | 3 +- 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/PaymentTypeInterface.php | 24 +++--- src/Base/PricingManagerInterface.php | 18 +++-- src/Base/ShippingManifest.php | 2 +- src/Base/ShippingManifestInterface.php | 6 +- src/Base/ShippingModifiers.php | 1 + src/Base/TaxDriver.php | 18 +++-- 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/Base/Traits/HasUrls.php | 2 +- src/Base/Traits/Searchable.php | 17 ++-- src/Console/Commands/Import/AddressData.php | 4 +- src/Console/Commands/ScoutIndexer.php | 5 +- src/Console/InstallGetCandy.php | 34 ++++---- src/DataTypes/Price.php | 13 ++-- src/Drivers/SystemTaxDriver.php | 5 +- 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/Generators/UrlGenerator.php | 12 +-- 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 | 57 ++++++++------ src/Managers/CartSessionManager.php | 14 ++-- src/Managers/PaymentManager.php | 8 +- src/Managers/PricingManager.php | 30 ++++--- src/Managers/TaxManager.php | 3 +- src/Models/Address.php | 8 +- src/Models/Attribute.php | 5 +- src/Models/Cart.php | 3 +- src/Models/Channel.php | 3 +- src/Models/Order.php | 26 +++---- src/Models/Product.php | 10 ++- src/Models/ProductAssociation.php | 14 ++-- src/Models/ProductVariant.php | 2 +- src/Models/Url.php | 3 +- src/Observers/AddressObserver.php | 10 ++- 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/OrderObserver.php | 5 +- src/Observers/TransactionObserver.php | 11 +-- src/Observers/UrlObserver.php | 12 ++- src/PaymentTypes/OfflinePayment.php | 6 +- src/Rules/MaxDecimalPlaces.php | 5 +- src/Utils/Arr.php | 2 +- tests/Stubs/TestTaxDriver.php | 5 +- tests/Stubs/TestUrlGenerator.php | 3 +- tests/Unit/Actions/Carts/CreateOrderTest.php | 6 +- tests/Unit/Base/MacroableModelTest.php | 3 +- tests/Unit/Managers/CartManagerTest.php | 78 +++++++++---------- .../Unit/Managers/CartSessionManagerTest.php | 8 +- tests/Unit/Models/CartTest.php | 2 +- tests/Unit/Models/OrderTest.php | 6 +- tests/Unit/Models/PriceTest.php | 14 ++-- tests/Unit/Models/ProductOptionTest.php | 2 +- tests/Unit/Models/ProductTest.php | 2 +- tests/Unit/Observers/AddressObserverTest.php | 8 +- tests/Unit/Observers/OrderObserverTest.php | 22 +++--- tests/Unit/Traits/HasUrlsTraitTest.php | 10 +-- 102 files changed, 561 insertions(+), 427 deletions(-) diff --git a/config/payments.php b/config/payments.php index 3c59b5ef..69c95d0f 100644 --- a/config/payments.php +++ b/config/payments.php @@ -5,7 +5,7 @@ 'types' => [ 'cash-in-hand' => [ - 'driver' => 'offline', + 'driver' => 'offline', 'released' => 'payment-offline', ], ], diff --git a/database/factories/OrderFactory.php b/database/factories/OrderFactory.php index 598efcf7..768a4bf1 100644 --- a/database/factories/OrderFactory.php +++ b/database/factories/OrderFactory.php @@ -26,8 +26,8 @@ public function definition(): array 'tax_breakdown' => [ [ 'description' => 'VAT', - 'total' => 200, - 'percentage' => 20, + 'total' => 200, + 'percentage' => 20, ], ], 'tax_total' => $taxTotal, diff --git a/database/factories/OrderLineFactory.php b/database/factories/OrderLineFactory.php index 6190edb4..021dd35d 100644 --- a/database/factories/OrderLineFactory.php +++ b/database/factories/OrderLineFactory.php @@ -30,8 +30,8 @@ public function definition(): array 'tax_breakdown' => [ [ 'description' => 'VAT', - 'total' => 200, - 'percentage' => 20, + 'total' => 200, + 'percentage' => 20, ], ], 'tax_total' => $this->faker->numberBetween(1, 5000), 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 54cdc8ef..eec1a91c 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 40576f17..c3d7fcdd 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 d63ee71e..af72bc02 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 32b00b98..3468f39d 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 3a497fe0..7aa28cc5 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 af87cf47..ce54188f 100644 --- a/src/Actions/Carts/CalculateLine.php +++ b/src/Actions/Carts/CalculateLine.php @@ -14,8 +14,9 @@ class CalculateLine /** * 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( @@ -29,7 +30,7 @@ public function execute( $unitQuantity = $purchasable->getUnitQuantity(); // we check if any cart line modifiers have already specified a unit price in their calculating() method - if (! ($price = $cartLine->unitPrice) instanceof Price) { + if (!($price = $cartLine->unitPrice) instanceof Price) { $priceResponse = Pricing::currency($cart->currency) ->qty($cartLine->quantity) ->currency($cart->currency) diff --git a/src/Actions/Carts/CreateOrder.php b/src/Actions/Carts/CreateOrder.php index f57fee46..89d8acc6 100644 --- a/src/Actions/Carts/CreateOrder.php +++ b/src/Actions/Carts/CreateOrder.php @@ -23,7 +23,8 @@ public function __construct(OrderReferenceGeneratorInterface $generator) /** * Execute the action. * - * @param \GetCandy\Models\Cart $cart + * @param \GetCandy\Models\Cart $cart + * * @return void */ public function execute( @@ -56,9 +57,9 @@ public function execute( 'tax_breakdown' => $cart->taxBreakdown->map(function ($tax) { return [ 'description' => $tax['description'], - 'identifier' => $tax['identifier'], - 'percentage' => $tax['amounts']->sum('percentage'), - 'total' => $tax['total']->value, + 'identifier' => $tax['identifier'], + 'percentage' => $tax['amounts']->sum('percentage'), + 'total' => $tax['total']->value, ]; })->values(), 'tax_total' => $cart->taxTotal->value, @@ -87,9 +88,9 @@ public function execute( 'tax_breakdown' => $line->taxBreakdown->amounts->map(function ($amount) { return [ 'description' => $amount->description, - 'identifier' => $amount->identifier, - 'percentage' => $amount->percentage, - 'total' => $amount->price->value, + 'identifier' => $amount->identifier, + 'percentage' => $amount->percentage, + 'total' => $amount->price->value, ]; })->values(), 'tax_total' => $line->taxAmount->value, @@ -127,9 +128,9 @@ public function execute( 'tax_breakdown' => $shippingAddress->taxBreakdown->amounts->map(function ($amount) { return [ 'description' => $amount->description, - 'identifier' => $amount->identifier, - 'percentage' => $amount->percentage, - 'total' => $amount->price->value, + 'identifier' => $amount->identifier, + 'percentage' => $amount->percentage, + 'total' => $amount->price->value, ]; })->values(), 'tax_total' => $shippingAddress->shippingTaxTotal->value, diff --git a/src/Actions/Carts/MergeCart.php b/src/Actions/Carts/MergeCart.php index e8380c91..4be0ae5a 100644 --- a/src/Actions/Carts/MergeCart.php +++ b/src/Actions/Carts/MergeCart.php @@ -10,8 +10,9 @@ 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 224609c4..7895a1d7 100644 --- a/src/Actions/Carts/ValidateCartForOrder.php +++ b/src/Actions/Carts/ValidateCartForOrder.php @@ -16,7 +16,8 @@ class ValidateCartForOrder /** * Execute the action. * - * @param \GetCandy\Models\Cart $cart + * @param \GetCandy\Models\Cart $cart + * * @return void */ public function execute( @@ -31,7 +32,7 @@ public function execute( } // Do we have a billing address? - if (! $cart->billingAddress) { + if (!$cart->billingAddress) { throw new BillingAddressMissingException( __('getcandy::exceptions.carts.billing_missing') ); @@ -48,7 +49,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') ); @@ -64,7 +65,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 dc9a12bc..7047c138 100644 --- a/src/Actions/Collections/SortProducts.php +++ b/src/Actions/Collections/SortProducts.php @@ -10,7 +10,8 @@ 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 aacd016e..7e71d639 100644 --- a/src/Actions/Collections/SortProductsByPrice.php +++ b/src/Actions/Collections/SortProductsByPrice.php @@ -11,9 +11,10 @@ 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 5e2c082d..b4d2667b 100644 --- a/src/Actions/Collections/SortProductsBySku.php +++ b/src/Actions/Collections/SortProductsBySku.php @@ -9,8 +9,9 @@ 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 929edff8..aef61aee 100644 --- a/src/Actions/Taxes/GetTaxZonePostcode.php +++ b/src/Actions/Taxes/GetTaxZonePostcode.php @@ -9,7 +9,8 @@ class GetTaxZonePostcode /** * Execute the action. * - * @param string $postcode + * @param string $postcode + * * @return null|\GetCandy\Models\TaxZonePostcode */ public function execute($postcode) @@ -20,7 +21,7 @@ public function execute($postcode) return $postcodeZone; } - if (! $postcodeZone) { + if (!$postcodeZone) { return null; } @@ -32,7 +33,7 @@ public function execute($postcode) })->sort(fn ($current, $next) => $current['matches'] < $next['matches'])->first(); // Give up, use default... - if (! $match) { + if (!$match) { return null; } @@ -42,7 +43,8 @@ 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) @@ -59,8 +61,9 @@ 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 efd6fa6d..ff6ccc36 100644 --- a/src/Addons/Manifest.php +++ b/src/Addons/Manifest.php @@ -43,12 +43,13 @@ 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 7c242baf..eb4bcc5e 100644 --- a/src/Base/AttributeManifestInterface.php +++ b/src/Base/AttributeManifestInterface.php @@ -9,7 +9,8 @@ interface AttributeManifestInterface /** * Add an attribute type. * - * @param string $classname + * @param string $classname + * * @return void */ public function addType($classname); @@ -24,7 +25,8 @@ 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 6548523d..cc056c89 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 = []) { @@ -30,8 +30,9 @@ 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) @@ -46,8 +47,9 @@ 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 7d724b46..2e3c3d29 100644 --- a/src/Base/CartSessionInterface.php +++ b/src/Base/CartSessionInterface.php @@ -33,9 +33,10 @@ 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); @@ -43,7 +44,8 @@ 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); @@ -58,7 +60,8 @@ 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); @@ -66,7 +69,8 @@ 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 f3c19bcd..5dd0b250 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 d7e34c7b..71cd2047 100644 --- a/src/Base/Casts/Price.php +++ b/src/Base/Casts/Price.php @@ -12,10 +12,11 @@ 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) @@ -43,10 +44,11 @@ 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 a24ddb84..7b1db53f 100644 --- a/src/Base/Casts/TaxBreakdown.php +++ b/src/Base/Casts/TaxBreakdown.php @@ -11,10 +11,11 @@ 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) @@ -33,10 +34,11 @@ 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/DataTransferObjects/TaxBreakdown.php b/src/Base/DataTransferObjects/TaxBreakdown.php index a2988a68..0a038067 100644 --- a/src/Base/DataTransferObjects/TaxBreakdown.php +++ b/src/Base/DataTransferObjects/TaxBreakdown.php @@ -15,7 +15,8 @@ public function __construct( /** * Add a tax breakdown amount. * - * @param TaxBreakdownAmount $taxBreakdownAmount + * @param TaxBreakdownAmount $taxBreakdownAmount + * * @return void */ public function addAmount(TaxBreakdownAmount $taxBreakdownAmount) diff --git a/src/Base/FieldType.php b/src/Base/FieldType.php index 31620e21..f9f5fc0d 100644 --- a/src/Base/FieldType.php +++ b/src/Base/FieldType.php @@ -14,7 +14,8 @@ 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 2303118f..e00b1263 100644 --- a/src/Base/FieldTypeManifest.php +++ b/src/Base/FieldTypeManifest.php @@ -35,16 +35,17 @@ 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 d6fd788e..6ad4e317 100644 --- a/src/Base/FieldTypeManifestInterface.php +++ b/src/Base/FieldTypeManifestInterface.php @@ -9,7 +9,8 @@ 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 79c8b434..07fbe74a 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,7 +53,8 @@ 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 218a820f..2b9cdc5c 100644 --- a/src/Base/OrderReferenceGeneratorInterface.php +++ b/src/Base/OrderReferenceGeneratorInterface.php @@ -9,7 +9,8 @@ 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/PaymentTypeInterface.php b/src/Base/PaymentTypeInterface.php index 8af7a203..59996f43 100644 --- a/src/Base/PaymentTypeInterface.php +++ b/src/Base/PaymentTypeInterface.php @@ -14,7 +14,8 @@ interface PaymentTypeInterface /** * Set the cart. * - * @param \GetCandy\Models\Cart $order + * @param \GetCandy\Models\Cart $order + * * @return self */ public function cart(Cart $cart): self; @@ -22,7 +23,8 @@ public function cart(Cart $cart): self; /** * Set the order. * - * @param Order $order + * @param Order $order + * * @return self */ public function order(Order $order): self; @@ -30,7 +32,8 @@ public function order(Order $order): self; /** * Set any data the provider might need. * - * @param array $data + * @param array $data + * * @return self */ public function withData(array $data): self; @@ -38,7 +41,8 @@ public function withData(array $data): self; /** * Set any configuration on the driver. * - * @param array $config + * @param array $config + * * @return self */ public function setConfig(array $config): self; @@ -53,9 +57,10 @@ public function release(): PaymentRelease; /** * Refund a transaction for a given amount. * - * @param \GetCandy\Models\Transaction $transaction - * @param int $amount - * @param null|string $notes + * @param \GetCandy\Models\Transaction $transaction + * @param int $amount + * @param null|string $notes + * * @return \GetCandy\Base\DataTransferObjects\PaymentRefund */ public function refund(Transaction $transaction, int $amount, $notes = null): PaymentRefund; @@ -63,8 +68,9 @@ public function refund(Transaction $transaction, int $amount, $notes = null): Pa /** * Capture an amount for a transaction. * - * @param \GetCandy\Models\Transaction $transaction - * @param int $amount + * @param \GetCandy\Models\Transaction $transaction + * @param int $amount + * * @return \GetCandy\Base\DataTransferObjects\PaymentCapture */ public function capture(Transaction $transaction, $amount = 0): PaymentCapture; diff --git a/src/Base/PricingManagerInterface.php b/src/Base/PricingManagerInterface.php index a119363e..a997f434 100644 --- a/src/Base/PricingManagerInterface.php +++ b/src/Base/PricingManagerInterface.php @@ -12,7 +12,8 @@ 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); @@ -20,7 +21,8 @@ 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); @@ -28,7 +30,8 @@ public function currency(Currency $currency); /** * Set the quantity property. * - * @param int $qty + * @param int $qty + * * @return self */ public function qty(int $qty); @@ -36,7 +39,8 @@ public function qty(int $qty); /** * Set the customer groups. * - * @param Collection $customerGroups + * @param Collection $customerGroups + * * @return self */ public function customerGroups(Collection $customerGroups); @@ -44,7 +48,8 @@ public function customerGroups(Collection $customerGroups); /** * Set the customer group. * - * @param CustomerGroup $customerGroup + * @param CustomerGroup $customerGroup + * * @return self */ public function customerGroup(CustomerGroup $customerGroup); @@ -52,7 +57,8 @@ 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 9bd3ff88..4298604c 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 c7dfcd15..fff14de2 100644 --- a/src/Base/ShippingManifestInterface.php +++ b/src/Base/ShippingManifestInterface.php @@ -11,7 +11,8 @@ 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); @@ -19,7 +20,8 @@ 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 b9769307..3c7966e1 100644 --- a/src/Base/ShippingModifiers.php +++ b/src/Base/ShippingModifiers.php @@ -35,6 +35,7 @@ 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 1e9a2a3b..ee0d4748 100644 --- a/src/Base/TaxDriver.php +++ b/src/Base/TaxDriver.php @@ -11,7 +11,8 @@ 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): self; @@ -19,7 +20,8 @@ public function setShippingAddress(Addressable $address = null): self; /** * Set the currency. * - * @param \GetCandy\Models\Currency $currency + * @param \GetCandy\Models\Currency $currency + * * @return self */ public function setCurrency(Currency $currency): self; @@ -27,7 +29,8 @@ public function setCurrency(Currency $currency): self; /** * Set the billing address. * - * @param \GetCandy\Base\Addressable|null $address + * @param \GetCandy\Base\Addressable|null $address + * * @return self */ public function setBillingAddress(Addressable $address = null): self; @@ -35,7 +38,8 @@ public function setBillingAddress(Addressable $address = null): self; /** * Set the purchasable item. * - * @param \GetCandy\Base\Purchasable $purchasable + * @param \GetCandy\Base\Purchasable $purchasable + * * @return self */ public function setPurchasable(Purchasable $purchasable): self; @@ -43,7 +47,8 @@ public function setPurchasable(Purchasable $purchasable): self; /** * Set the cart line. * - * @param \GetCandy\Models\CartLine $cartLine + * @param \GetCandy\Models\CartLine $cartLine + * * @return self */ public function setCartLine(CartLine $cartLine): self; @@ -51,7 +56,8 @@ public function setCartLine(CartLine $cartLine): self; /** * Return the tax breakdown from a given sub total. * - * @param int $subTotal + * @param int $subTotal + * * @return \GetCandy\Base\DataTransferObjects\TaxBreakdown */ public function getBreakdown($subTotal): TaxBreakdown; diff --git a/src/Base/Traits/CanScheduleAvailability.php b/src/Base/Traits/CanScheduleAvailability.php index 40995d97..10c90662 100644 --- a/src/Base/Traits/CanScheduleAvailability.php +++ b/src/Base/Traits/CanScheduleAvailability.php @@ -12,7 +12,8 @@ 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); @@ -20,11 +21,12 @@ 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( @@ -37,13 +39,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); } @@ -61,9 +63,10 @@ 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 = []) @@ -71,13 +74,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); } @@ -93,8 +96,9 @@ 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 a8eb2605..da4a4488 100644 --- a/src/Base/Traits/HasCustomerGroups.php +++ b/src/Base/Traits/HasCustomerGroups.php @@ -21,10 +21,11 @@ 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( @@ -45,8 +46,9 @@ 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( @@ -63,7 +65,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 83f8eafd..9a8ab8d1 100644 --- a/src/Base/Traits/HasDefaultRecord.php +++ b/src/Base/Traits/HasDefaultRecord.php @@ -7,7 +7,8 @@ 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 1a97f61c..75698b65 100644 --- a/src/Base/Traits/HasTranslations.php +++ b/src/Base/Traits/HasTranslations.php @@ -10,8 +10,9 @@ 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) @@ -22,7 +23,7 @@ public function translate($attribute, $locale = null) return $values; } - if (! $values) { + if (!$values) { return null; } @@ -41,28 +42,29 @@ 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; } @@ -70,7 +72,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/Base/Traits/HasUrls.php b/src/Base/Traits/HasUrls.php index e9e97fdc..47f1a70a 100644 --- a/src/Base/Traits/HasUrls.php +++ b/src/Base/Traits/HasUrls.php @@ -22,7 +22,7 @@ public static function bootHasUrls() }); static::deleted(function (Model $model) { - if (! $model->deleted_at) { + if (!$model->deleted_at) { $model->urls()->delete(); } }); diff --git a/src/Base/Traits/Searchable.php b/src/Base/Traits/Searchable.php index 63e8dab2..fa1679c4 100644 --- a/src/Base/Traits/Searchable.php +++ b/src/Base/Traits/Searchable.php @@ -59,13 +59,14 @@ public function getFilterableAttributes() /** * Add additional fields to filter on. * - * @param array $attributes + * @param array $attributes + * * @return void */ public function addFilterableAttributes(array $attributes) { collect($attributes)->filter(function ($att) { - return ! in_array($att, $this->filterable) && ! in_array($att, $this->additionalFilterableFields); + return !in_array($att, $this->filterable) && !in_array($att, $this->additionalFilterableFields); })->each(function ($att) { $this->additionalFilterableFields[] = $att; }); @@ -74,13 +75,14 @@ public function addFilterableAttributes(array $attributes) /** * Add additional sortable attributes. * - * @param array $attributes + * @param array $attributes + * * @return void */ public function addSortableAttributes(array $attributes) { collect($attributes)->filter(function ($att) { - return ! in_array($att, $this->sortable) && ! in_array($att, $this->additionalSortableFields); + return !in_array($att, $this->sortable) && !in_array($att, $this->additionalSortableFields); })->each(function ($att) { $this->additionalSortableFields[] = $att; }); @@ -115,13 +117,14 @@ public function getObservableEvents() /** * Add an attribute into the additional searchable fields. * - * @param string $key - * @param string|mixed $value + * @param string $key + * @param string|mixed $value + * * @return void */ public function addSearchableAttribute($key, $value) { - if (! isset($this->additionalSearchFields[$key])) { + if (!isset($this->additionalSearchFields[$key])) { $this->additionalSearchFields[$key] = $value; } } diff --git a/src/Console/Commands/Import/AddressData.php b/src/Console/Commands/Import/AddressData.php index 8c97b84c..7594563b 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/Commands/ScoutIndexer.php b/src/Console/Commands/ScoutIndexer.php index a05f469d..4fc5b774 100644 --- a/src/Console/Commands/ScoutIndexer.php +++ b/src/Console/Commands/ScoutIndexer.php @@ -37,7 +37,8 @@ public function __construct() /** * Executes the re-index of the informed models. * - * @param array $models Models array for indexing + * @param array $models Models array for indexing + * * @return void */ private function indexer(array $models): void @@ -53,7 +54,7 @@ private function indexer(array $models): void } // Checks whether to import the records - if (! $this->option('flush')) { + if (!$this->option('flush')) { // Import model records to index $this->call('scout:import', ['model' => $model]); } diff --git a/src/Console/InstallGetCandy.php b/src/Console/InstallGetCandy.php index 8b0a3c07..459b1198 100644 --- a/src/Console/InstallGetCandy.php +++ b/src/Console/InstallGetCandy.php @@ -60,7 +60,7 @@ public function handle(): void $confirmed = $this->confirm('I understand, lets do this 🚀'); - if (! $confirmed) { + if (!$confirmed) { $this->info('😔 Understood, if you have concerns, please reach out to us on Discord, https://discord.gg/v6qVWaf'); return; @@ -71,7 +71,7 @@ public function handle(): void $this->info('Publishing configuration...'); - if (! $this->configExists('getcandy')) { + if (!$this->configExists('getcandy')) { $this->publishConfiguration(); } else { if ($this->shouldOverwriteConfig()) { @@ -84,12 +84,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([ @@ -100,7 +100,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?'); @@ -117,7 +117,7 @@ public function handle(): void ]); } - if (! Language::count()) { + if (!Language::count()) { $this->info('Adding default language'); Language::create([ @@ -127,7 +127,7 @@ public function handle(): void ]); } - if (! Currency::whereDefault(true)->exists()) { + if (!Currency::whereDefault(true)->exists()) { $this->info('Adding a default currency (USD)'); Currency::create([ @@ -140,7 +140,7 @@ public function handle(): void ]); } - if (! CustomerGroup::whereDefault(true)->exists()) { + if (!CustomerGroup::whereDefault(true)->exists()) { $this->info('Adding a default customer group.'); CustomerGroup::create([ @@ -150,7 +150,7 @@ public function handle(): void ]); } - if (! CollectionGroup::count()) { + if (!CollectionGroup::count()) { $this->info('Adding an initial collection group'); CollectionGroup::create([ @@ -159,7 +159,7 @@ public function handle(): void ]); } - if (! TaxClass::count()) { + if (!TaxClass::count()) { $this->info('Adding a default tax class.'); TaxClass::create([ @@ -168,7 +168,7 @@ public function handle(): void ]); } - if (! Attribute::count()) { + if (!Attribute::count()) { $this->info('Setting up initial attributes'); $group = AttributeGroup::create([ @@ -262,7 +262,7 @@ public function handle(): void ]); } - if (! ProductType::count()) { + if (!ProductType::count()) { $this->info('Adding a product type.'); $type = ProductType::create([ @@ -289,16 +289,17 @@ 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))); } /** @@ -317,7 +318,8 @@ 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 f557147e..dcc67ccc 100644 --- a/src/DataTypes/Price.php +++ b/src/DataTypes/Price.php @@ -12,16 +12,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"' ); @@ -34,7 +34,8 @@ public function __construct( /** * Getter for methods/properties. * - * @param string $name + * @param string $name + * * @return void */ public function __get($name) @@ -74,7 +75,7 @@ protected function decimal() */ public function formatted($locale = null, $formatter = NumberFormatter::CURRENCY) { - if (! $locale) { + if (!$locale) { $locale = App::currentLocale(); } diff --git a/src/Drivers/SystemTaxDriver.php b/src/Drivers/SystemTaxDriver.php index da0d5b57..75d44de4 100644 --- a/src/Drivers/SystemTaxDriver.php +++ b/src/Drivers/SystemTaxDriver.php @@ -92,7 +92,8 @@ public function setPurchasable(Purchasable $purchasable): self /** * Set the cart line. * - * @param CartLine $cartLine + * @param CartLine $cartLine + * * @return self */ public function setCartLine(CartLine $cartLine): self @@ -111,7 +112,7 @@ public function getBreakdown($subTotal): TaxBreakdown $taxClass = $this->purchasable->getTaxClass(); $taxAmounts = $taxZone->taxAmounts()->whereTaxClassId($taxClass->id)->get(); - $breakdown = new TaxBreakdown; + $breakdown = new TaxBreakdown(); foreach ($taxAmounts as $amount) { $result = round($subTotal * ($amount->percentage / 100)); diff --git a/src/FieldTypes/Dropdown.php b/src/FieldTypes/Dropdown.php index d47001cf..592febe1 100644 --- a/src/FieldTypes/Dropdown.php +++ b/src/FieldTypes/Dropdown.php @@ -16,7 +16,7 @@ class Dropdown implements FieldType, JsonSerializable /** * Create a new instance of List field type. * - * @param string|int $value + * @param string|int $value */ public function __construct($value = '') { @@ -46,11 +46,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 5eb2ad7b..3893634f 100644 --- a/src/FieldTypes/ListField.php +++ b/src/FieldTypes/ListField.php @@ -16,7 +16,7 @@ class ListField implements FieldType, JsonSerializable /** * Create a new instance of List field type. * - * @param int|float $value + * @param int|float $value */ public function __construct($value = []) { @@ -46,11 +46,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 1de85ccd..23e58716 100644 --- a/src/FieldTypes/Number.php +++ b/src/FieldTypes/Number.php @@ -16,7 +16,7 @@ class Number implements FieldType, JsonSerializable /** * Create a new instance of Number field type. * - * @param int|float $value + * @param int|float $value */ public function __construct($value = 0) { @@ -46,11 +46,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)) && $value !== '') { + if ((!is_numeric($value)) && $value !== '') { throw new FieldTypeException(self::class.' value must be numeric.'); } diff --git a/src/FieldTypes/Text.php b/src/FieldTypes/Text.php index 7af33e37..dedfad0b 100644 --- a/src/FieldTypes/Text.php +++ b/src/FieldTypes/Text.php @@ -26,7 +26,7 @@ public function jsonSerialize(): mixed /** * 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 d680ae06..1ca5686f 100644 --- a/src/FieldTypes/Toggle.php +++ b/src/FieldTypes/Toggle.php @@ -26,7 +26,7 @@ public function jsonSerialize(): mixed /** * 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 83faeec7..920d512b 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/Generators/UrlGenerator.php b/src/Generators/UrlGenerator.php index 0e7afd23..19a30254 100644 --- a/src/Generators/UrlGenerator.php +++ b/src/Generators/UrlGenerator.php @@ -33,14 +33,15 @@ public function __construct() /** * Handle the URL generation. * - * @param \Illuminate\Database\Eloquent\Model $model + * @param \Illuminate\Database\Eloquent\Model $model + * * @return void */ public function handle(Model $model) { $this->model = $model; - if (! $model->urls->count()) { + if (!$model->urls->count()) { if ($model->attribute_data) { return $this->createFromAttribute('name'); } @@ -50,7 +51,8 @@ public function handle(Model $model) /** * Create default url from an attribute. * - * @param string $attribute + * @param string $attribute + * * @return void */ protected function createFromAttribute($attribute) @@ -60,9 +62,9 @@ protected function createFromAttribute($attribute) ); $this->model->urls()->create([ - 'default' => true, + 'default' => true, 'language_id' => $this->defaultLanguage->id, - 'slug' => $slug, + 'slug' => $slug, ]); } } diff --git a/src/GetCandyServiceProvider.php b/src/GetCandyServiceProvider.php index c9cd4417..54a2b96f 100644 --- a/src/GetCandyServiceProvider.php +++ b/src/GetCandyServiceProvider.php @@ -160,7 +160,7 @@ public function boot(): void $this->registerObservers(); $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 fcdae66d..d258866f 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 0d4e619e..11172653 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 3e7f8a75..1b0772f9 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 d4d9be7d..71bc5027 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 994bee9e..3d216313 100644 --- a/src/Jobs/SyncTags.php +++ b/src/Jobs/SyncTags.php @@ -39,8 +39,9 @@ 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 addb7250..9c088ef2 100644 --- a/src/Listeners/CartSessionAuthListener.php +++ b/src/Listeners/CartSessionAuthListener.php @@ -22,14 +22,15 @@ 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, @@ -37,7 +38,7 @@ public function login(Login $event) ); } - if (! $currentCart) { + if (!$currentCart) { // Does this user have a cart? $userCart = Cart::whereUserId($event->user->getKey())->active()->first(); @@ -50,7 +51,8 @@ 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 5cfad39b..2d2851ff 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 9880e7e7..3acfff7e 100644 --- a/src/Managers/CartManager.php +++ b/src/Managers/CartManager.php @@ -48,7 +48,7 @@ class CartManager /** * Initialize the cart manager. * - * @param Cart $cart + * @param Cart $cart */ public function __construct( protected Cart $cart, @@ -117,10 +117,10 @@ public function calculate() $this->cart->taxBreakdown = $taxBreakDownAmounts->groupBy('identifier')->map(function ($amounts) { return [ 'percentage' => $amounts->first()->percentage, - 'description' => $amounts->first()->description, - 'identifier' => $amounts->first()->identifier, - 'amounts' => $amounts, - 'total' => new Price($amounts->sum('price.value'), $this->cart->currency, 1), + 'description' => $amounts->first()->description, + 'identifier' => $amounts->first()->identifier, + 'amounts' => $amounts, + 'total' => new Price($amounts->sum('price.value'), $this->cart->currency, 1), ]; }); @@ -146,9 +146,10 @@ 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 = []) @@ -193,10 +194,11 @@ public function add(Purchasable $purchasable, int $quantity = 1, $meta = []) /** * Remove a cart line from the cart. * - * @param int|string $cartLineId - * @return \GetCandy\Models\Cart + * @param int|string $cartLineId * * @throws \GetCandy\Exceptions\CartLineIdMismatchException + * + * @return \GetCandy\Models\Cart */ public function removeLine($cartLineId) { @@ -204,7 +206,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') ); @@ -228,7 +230,8 @@ public function clear() /** * Update cart lines. * - * @param Collection $lines + * @param Collection $lines + * * @return \GetCandy\Models\Cart */ public function updateLines(Collection $lines) @@ -249,9 +252,10 @@ 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) @@ -277,8 +281,9 @@ 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') @@ -309,7 +314,8 @@ 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) @@ -324,7 +330,8 @@ 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) @@ -339,14 +346,15 @@ public function setBillingAddress(array|Addressable $address) /** * Set the shipping option to the shipping address. * - * @param ShippingOption $option - * @return self + * @param ShippingOption $option * * @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; @@ -362,7 +370,7 @@ public function setShippingOption(ShippingOption $option) public function getShippingOption() { - if (! $this->cart->shippingAddress) { + if (!$this->cart->shippingAddress) { return null; } @@ -409,8 +417,9 @@ 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 5b124f20..1b86d11e 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,7 +81,8 @@ 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) @@ -90,7 +91,7 @@ private function fetchOrCreate($create = false) $this->getSessionKey() ); - if (! $cartId) { + if (!$cartId) { return $create ? $this->cart = $this->createNewCart() : null; } @@ -98,8 +99,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; } @@ -180,7 +181,8 @@ public function getShippingOptions() /** * Create an order from a cart instance. * - * @param bool $forget + * @param bool $forget + * * @return \GetCandy\Models\Order */ public function createOrder($forget = true) diff --git a/src/Managers/PaymentManager.php b/src/Managers/PaymentManager.php index 4e799d53..6865034c 100644 --- a/src/Managers/PaymentManager.php +++ b/src/Managers/PaymentManager.php @@ -16,10 +16,11 @@ public function createOfflineDriver() /** * Create a new driver instance. * - * @param string $driver - * @return mixed + * @param string $driver * * @throws \InvalidArgumentException + * + * @return mixed */ protected function createDriver($driver) { @@ -54,7 +55,8 @@ protected function createDriver($driver) /** * Build a tax provider instance. * - * @param string $provider + * @param string $provider + * * @return mixed */ public function buildProvider($provider) diff --git a/src/Managers/PricingManager.php b/src/Managers/PricingManager.php index 9ed6b35c..be7843c7 100644 --- a/src/Managers/PricingManager.php +++ b/src/Managers/PricingManager.php @@ -57,7 +57,8 @@ public function __construct() /** * Set the purchasable property. * - * @param \GetCandy\Base\Purchasable $purchasable + * @param \GetCandy\Base\Purchasable $purchasable + * * @return self */ public function for(Purchasable $purchasable) @@ -70,7 +71,8 @@ public function for(Purchasable $purchasable) /** * Set the user property. * - * @param \Illuminate\Contracts\Auth\Authenticatable $user + * @param \Illuminate\Contracts\Auth\Authenticatable $user + * * @return self */ public function user(?Authenticatable $user) @@ -95,7 +97,8 @@ public function guest() /** * Set the currency property. * - * @param \GetCandy\Models\Currency $currency + * @param \GetCandy\Models\Currency $currency + * * @return self */ public function currency(?Currency $currency) @@ -108,7 +111,8 @@ public function currency(?Currency $currency) /** * Set the quantity property. * - * @param int $qty + * @param int $qty + * * @return self */ public function qty(int $qty) @@ -121,7 +125,8 @@ public function qty(int $qty) /** * Set the customer groups. * - * @param Collection $customerGroups + * @param Collection $customerGroups + * * @return self */ public function customerGroups(?Collection $customerGroups) @@ -134,7 +139,8 @@ public function customerGroups(?Collection $customerGroups) /** * Set the customer group. * - * @param CustomerGroup $customerGroup + * @param CustomerGroup $customerGroup + * * @return self */ public function customerGroup(?CustomerGroup $customerGroup) @@ -153,15 +159,15 @@ public function customerGroup(?CustomerGroup $customerGroup) */ public function get() { - if (! $this->purchasable) { + if (!$this->purchasable) { throw new \ErrorException('No purchasable set.'); } - 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() ); @@ -181,19 +187,19 @@ public function get() 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; diff --git a/src/Managers/TaxManager.php b/src/Managers/TaxManager.php index 0113cf1e..be5cb744 100644 --- a/src/Managers/TaxManager.php +++ b/src/Managers/TaxManager.php @@ -15,7 +15,8 @@ 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 06b2ac92..eddcd44f 100644 --- a/src/Models/Address.php +++ b/src/Models/Address.php @@ -36,13 +36,14 @@ protected static function newFactory(): AddressFactory */ protected $casts = [ 'shipping_default' => 'boolean', - 'billing_default' => 'boolean', + 'billing_default' => 'boolean', ]; /** * Mutator for the meta attribute. * - * @param array|null $value + * @param array|null $value + * * @return void */ public function setMetaAttribute(array $value = null) @@ -55,7 +56,8 @@ 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 4fbba2cf..af3d8337 100644 --- a/src/Models/Attribute.php +++ b/src/Models/Attribute.php @@ -79,8 +79,9 @@ 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/Cart.php b/src/Models/Cart.php index 34b3197b..7591ae46 100644 --- a/src/Models/Cart.php +++ b/src/Models/Cart.php @@ -175,7 +175,8 @@ public function getManager() /** * Apply scope to get active cart. * - * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $query + * * @return void */ public function scopeActive(Builder $query) diff --git a/src/Models/Channel.php b/src/Models/Channel.php index ebf3d8d3..8e7671df 100644 --- a/src/Models/Channel.php +++ b/src/Models/Channel.php @@ -38,7 +38,8 @@ 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/Order.php b/src/Models/Order.php index ed1206cd..385cbd5e 100644 --- a/src/Models/Order.php +++ b/src/Models/Order.php @@ -12,9 +12,9 @@ class Order extends BaseModel { - use HasFactory, - Searchable, - LogsActivity; + use HasFactory; + use Searchable; + use LogsActivity; /** * Define our base filterable attributes. @@ -258,17 +258,17 @@ public function user() protected function getSearchableAttributes() { $data = [ - 'id' => $this->id, - 'channel' => $this->channel->name, - 'reference' => $this->reference, + 'id' => $this->id, + 'channel' => $this->channel->name, + 'reference' => $this->reference, 'customer_reference' => $this->customer_reference, - 'status' => $this->status, - 'placed_at' => optional($this->placed_at)->timestamp, - 'created_at' => $this->created_at->timestamp, - 'sub_total' => $this->sub_total->value, - 'total' => $this->total->value, - 'currency_code' => $this->currency_code, - 'charges' => $this->transactions->map(function ($transaction) { + 'status' => $this->status, + 'placed_at' => optional($this->placed_at)->timestamp, + 'created_at' => $this->created_at->timestamp, + 'sub_total' => $this->sub_total->value, + 'total' => $this->total->value, + 'currency_code' => $this->currency_code, + 'charges' => $this->transactions->map(function ($transaction) { return [ 'reference' => $transaction->reference, ]; diff --git a/src/Models/Product.php b/src/Models/Product.php index af7501e7..5296f44f 100644 --- a/src/Models/Product.php +++ b/src/Models/Product.php @@ -169,8 +169,9 @@ public function inverseAssociations() /** * 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) @@ -181,8 +182,9 @@ 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 762fdc4d..e0b27d4a 100644 --- a/src/Models/ProductAssociation.php +++ b/src/Models/ProductAssociation.php @@ -72,7 +72,8 @@ 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) @@ -83,7 +84,8 @@ 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) @@ -94,7 +96,8 @@ 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) @@ -105,8 +108,9 @@ 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/ProductVariant.php b/src/Models/ProductVariant.php index b8ea93cb..c9da2e62 100644 --- a/src/Models/ProductVariant.php +++ b/src/Models/ProductVariant.php @@ -171,7 +171,7 @@ public function getThumbnail() return $variantThumbnail->getUrl('small'); } - if (! $this->product) { + if (!$this->product) { dD($this); } // dd($this->product); diff --git a/src/Models/Url.php b/src/Models/Url.php index 810e1012..bb66c9e7 100644 --- a/src/Models/Url.php +++ b/src/Models/Url.php @@ -60,7 +60,8 @@ 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/AddressObserver.php b/src/Observers/AddressObserver.php index 9de89fe6..c8158661 100644 --- a/src/Observers/AddressObserver.php +++ b/src/Observers/AddressObserver.php @@ -9,7 +9,8 @@ class AddressObserver /** * Handle the Address "creating" event. * - * @param \GetCandy\Models\Address $address + * @param \GetCandy\Models\Address $address + * * @return void */ public function creating(Address $address) @@ -21,7 +22,8 @@ public function creating(Address $address) /** * Handle the Address "updating" event. * - * @param \GetCandy\Models\Address $address + * @param \GetCandy\Models\Address $address + * * @return void */ public function updating(Address $address) @@ -33,7 +35,7 @@ public function updating(Address $address) /** * Ensures that only one default shipping address exists. * - * @param Address $address The address that will be saved. + * @param Address $address The address that will be saved. */ protected function ensureOnlyOneDefaultShipping(Address $address): void { @@ -54,7 +56,7 @@ protected function ensureOnlyOneDefaultShipping(Address $address): void /** * Ensures that only one default billing address exists. * - * @param Address $address The address that will be saved. + * @param Address $address The address that will be saved. */ protected function ensureOnlyOneDefaultBilling(Address $address): void { diff --git a/src/Observers/CartLineObserver.php b/src/Observers/CartLineObserver.php index b427f631..e0eadae3 100644 --- a/src/Observers/CartLineObserver.php +++ b/src/Observers/CartLineObserver.php @@ -11,12 +11,13 @@ 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); } } @@ -24,12 +25,13 @@ 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 03eefb21..1a11b3c9 100644 --- a/src/Observers/ChannelObserver.php +++ b/src/Observers/ChannelObserver.php @@ -9,7 +9,8 @@ class ChannelObserver /** * Handle the User "created" event. * - * @param \GetCandy\Models\Channel $channel + * @param \GetCandy\Models\Channel $channel + * * @return void */ public function created(Channel $channel) @@ -20,7 +21,8 @@ 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) @@ -31,7 +33,8 @@ 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) @@ -42,7 +45,8 @@ 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) @@ -53,7 +57,8 @@ 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 a5ecca9c..58344364 100644 --- a/src/Observers/CollectionObserver.php +++ b/src/Observers/CollectionObserver.php @@ -10,7 +10,8 @@ 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 06ff8f1e..b02bb10e 100644 --- a/src/Observers/CurrencyObserver.php +++ b/src/Observers/CurrencyObserver.php @@ -9,7 +9,8 @@ class CurrencyObserver /** * Handle the Currency "created" event. * - * @param \GetCandy\Models\Currency $currency + * @param \GetCandy\Models\Currency $currency + * * @return void */ public function created(Currency $currency) @@ -20,7 +21,8 @@ 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) @@ -31,7 +33,8 @@ 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) @@ -42,7 +45,8 @@ 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) @@ -53,7 +57,8 @@ 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 abd09e81..2a3d75fc 100644 --- a/src/Observers/LanguageObserver.php +++ b/src/Observers/LanguageObserver.php @@ -9,7 +9,8 @@ class LanguageObserver /** * Handle the Language "created" event. * - * @param \GetCandy\Models\Language $language + * @param \GetCandy\Models\Language $language + * * @return void */ public function created(Language $language) @@ -20,7 +21,8 @@ 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) @@ -31,7 +33,8 @@ 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) @@ -42,7 +45,8 @@ 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) @@ -53,7 +57,8 @@ 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 4a13ec97..e7e35b13 100644 --- a/src/Observers/OrderLineObserver.php +++ b/src/Observers/OrderLineObserver.php @@ -11,12 +11,13 @@ 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); } } @@ -24,12 +25,13 @@ 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/OrderObserver.php b/src/Observers/OrderObserver.php index 85a7fe45..8fe9d038 100644 --- a/src/Observers/OrderObserver.php +++ b/src/Observers/OrderObserver.php @@ -9,7 +9,8 @@ class OrderObserver /** * Handle the OrderLine "updated" event. * - * @param \GetCandy\Models\OrderLine $orderLine + * @param \GetCandy\Models\OrderLine $orderLine + * * @return void */ public function updating(Order $order) @@ -20,7 +21,7 @@ public function updating(Order $order) ->performedOn($order) ->event('status-update') ->withProperties([ - 'new' => $order->status, + 'new' => $order->status, 'previous' => $order->getOriginal('status'), ])->log('status-update'); } diff --git a/src/Observers/TransactionObserver.php b/src/Observers/TransactionObserver.php index 9b58bf4c..ea460adb 100644 --- a/src/Observers/TransactionObserver.php +++ b/src/Observers/TransactionObserver.php @@ -9,7 +9,8 @@ class TransactionObserver /** * Handle the OrderLine "updated" event. * - * @param \GetCandy\Models\OrderLine $orderLine + * @param \GetCandy\Models\OrderLine $orderLine + * * @return void */ public function created(Transaction $transaction) @@ -19,13 +20,13 @@ public function created(Transaction $transaction) ->performedOn($transaction->order) ->event($transaction->type) ->withProperties([ - 'amount' => $transaction->amount->value, - 'refund' => $transaction->refund, - 'status' => $transaction->status, + 'amount' => $transaction->amount->value, + 'refund' => $transaction->refund, + 'status' => $transaction->status, 'card_type' => $transaction->card_type, 'last_four' => $transaction->last_four, 'reference' => $transaction->reference, - 'notes' => $transaction->notes, + 'notes' => $transaction->notes, ])->log('created'); } } diff --git a/src/Observers/UrlObserver.php b/src/Observers/UrlObserver.php index 27b325be..34b89f3e 100644 --- a/src/Observers/UrlObserver.php +++ b/src/Observers/UrlObserver.php @@ -9,7 +9,8 @@ class UrlObserver /** * Handle the Url "created" event. * - * @param \GetCandy\Models\Url $url + * @param \GetCandy\Models\Url $url + * * @return void */ public function created(Url $url) @@ -20,7 +21,8 @@ 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) @@ -31,7 +33,8 @@ 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) @@ -54,7 +57,8 @@ 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/PaymentTypes/OfflinePayment.php b/src/PaymentTypes/OfflinePayment.php index 8e55ae99..15e7d73f 100644 --- a/src/PaymentTypes/OfflinePayment.php +++ b/src/PaymentTypes/OfflinePayment.php @@ -14,14 +14,14 @@ class OfflinePayment extends AbstractPayment */ public function release(): PaymentRelease { - if (! $this->order) { - if (! $this->order = $this->cart->order) { + if (!$this->order) { + if (!$this->order = $this->cart->order) { $this->order = $this->cart->getManager()->createOrder(); } } $this->order->update([ - 'status' => $this->config['released'] ?? null, + 'status' => $this->config['released'] ?? null, 'placed_at' => now(), ]); diff --git a/src/Rules/MaxDecimalPlaces.php b/src/Rules/MaxDecimalPlaces.php index c8328e34..b43c706e 100644 --- a/src/Rules/MaxDecimalPlaces.php +++ b/src/Rules/MaxDecimalPlaces.php @@ -16,8 +16,9 @@ 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 9e0dcd82..b16d6f12 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/Stubs/TestTaxDriver.php b/tests/Stubs/TestTaxDriver.php index 026d3201..0c0249eb 100644 --- a/tests/Stubs/TestTaxDriver.php +++ b/tests/Stubs/TestTaxDriver.php @@ -86,7 +86,8 @@ public function setPurchasable(Purchasable $purchasable): self /** * Set the cart line. * - * @param CartLine $cartLine + * @param CartLine $cartLine + * * @return self */ public function setCartLine(CartLine $cartLine): self @@ -101,7 +102,7 @@ public function setCartLine(CartLine $cartLine): self */ public function getBreakdown($subTotal): TaxBreakdown { - $breakdown = new TaxBreakdown; + $breakdown = new TaxBreakdown(); $taxAmount = TaxRateAmount::factory()->create(); diff --git a/tests/Stubs/TestUrlGenerator.php b/tests/Stubs/TestUrlGenerator.php index 2e336be5..d2c43eba 100644 --- a/tests/Stubs/TestUrlGenerator.php +++ b/tests/Stubs/TestUrlGenerator.php @@ -16,7 +16,8 @@ class TestUrlGenerator /** * Handle the URL generation. * - * @param \Illuminate\Database\Eloquent\Model $model + * @param \Illuminate\Database\Eloquent\Model $model + * * @return void */ public function handle(Model $model) diff --git a/tests/Unit/Actions/Carts/CreateOrderTest.php b/tests/Unit/Actions/Carts/CreateOrderTest.php index dfac3445..ce91bbab 100644 --- a/tests/Unit/Actions/Carts/CreateOrderTest.php +++ b/tests/Unit/Actions/Carts/CreateOrderTest.php @@ -122,9 +122,9 @@ public function can_create_order() $breakdown = $this->cart->taxBreakdown->map(function ($tax) { return [ 'description' => $tax['description'], - 'identifier' => $tax['identifier'], - 'percentage' => $tax['amounts']->sum('percentage'), - 'total' => $tax['total']->value, + 'identifier' => $tax['identifier'], + 'percentage' => $tax['amounts']->sum('percentage'), + 'total' => $tax['total']->value, ]; })->values(); diff --git a/tests/Unit/Base/MacroableModelTest.php b/tests/Unit/Base/MacroableModelTest.php index 1642c832..bd5a930c 100644 --- a/tests/Unit/Base/MacroableModelTest.php +++ b/tests/Unit/Base/MacroableModelTest.php @@ -33,8 +33,7 @@ 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 99cacf17..e99e0ac9 100644 --- a/tests/Unit/Managers/CartManagerTest.php +++ b/tests/Unit/Managers/CartManagerTest.php @@ -302,20 +302,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, ]); } @@ -330,59 +330,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 */ @@ -807,17 +807,17 @@ public function can_create_order() $cart = Cart::factory()->create([ 'currency_id' => $currency->id, - 'channel_id' => $channel->id, + 'channel_id' => $channel->id, ]); $shipping = CartAddress::factory()->create([ 'cart_id' => $cart->id, - 'type' => 'shipping', + 'type' => 'shipping', ]); $billing = CartAddress::factory()->create([ 'cart_id' => $cart->id, - 'type' => 'billing', + 'type' => 'billing', ]); $cart->getManager()->setShippingAddress($shipping); @@ -844,7 +844,7 @@ public function cant_create_order_from_incomplete_cart() $cart = Cart::factory()->create([ 'currency_id' => $currency->id, - 'channel_id' => $channel->id, + 'channel_id' => $channel->id, ]); $this->expectException(BillingAddressMissingException::class); @@ -852,9 +852,9 @@ public function cant_create_order_from_incomplete_cart() $cart->getManager()->createOrder(); Cart::create([ - 'cart_id' => $cart->id, + 'cart_id' => $cart->id, 'postcode' => 'foobar', - 'type' => 'billing', + 'type' => 'billing', ]); $this->expectException(BillingAddressIncompleteException::class); @@ -879,18 +879,18 @@ public function cant_create_order_for_cart_with_existing_order() $cart = Cart::factory()->create([ 'currency_id' => $currency->id, - 'channel_id' => $channel->id, - 'order_id' => $order->id, + 'channel_id' => $channel->id, + 'order_id' => $order->id, ]); CartAddress::factory()->create([ 'cart_id' => $cart->id, - 'type' => 'shipping', + 'type' => 'shipping', ]); CartAddress::factory()->create([ 'cart_id' => $cart->id, - 'type' => 'billing', + 'type' => 'billing', ]); $this->expectException(OrderExistsException::class); diff --git a/tests/Unit/Managers/CartSessionManagerTest.php b/tests/Unit/Managers/CartSessionManagerTest.php index fe1e49f6..6e217f57 100644 --- a/tests/Unit/Managers/CartSessionManagerTest.php +++ b/tests/Unit/Managers/CartSessionManagerTest.php @@ -82,12 +82,12 @@ public function can_create_order_from_session_cart_and_cleanup() $shipping = CartAddress::factory()->create([ 'cart_id' => $cart->id, - 'type' => 'shipping', + 'type' => 'shipping', ]); $billing = CartAddress::factory()->create([ 'cart_id' => $cart->id, - 'type' => 'billing', + 'type' => 'billing', ]); $cart->getManager()->setShippingAddress($shipping); @@ -127,12 +127,12 @@ public function can_create_order_from_session_cart_and_retain_cart() $shipping = CartAddress::factory()->create([ 'cart_id' => $cart->id, - 'type' => 'shipping', + 'type' => 'shipping', ]); $billing = CartAddress::factory()->create([ 'cart_id' => $cart->id, - 'type' => 'billing', + 'type' => 'billing', ]); $cart->getManager()->setShippingAddress($shipping); diff --git a/tests/Unit/Models/CartTest.php b/tests/Unit/Models/CartTest.php index efe47af1..b86b2e1c 100644 --- a/tests/Unit/Models/CartTest.php +++ b/tests/Unit/Models/CartTest.php @@ -98,7 +98,7 @@ public function will_not_retrieve_user_cart_if_order_is_present() $user = StubUser::factory()->create(); $cart = Cart::create([ - 'order_id' => Order::factory()->create()->id, + 'order_id' => Order::factory()->create()->id, 'currency_id' => $currency->id, 'channel_id' => $channel->id, 'user_id' => $user->getKey(), diff --git a/tests/Unit/Models/OrderTest.php b/tests/Unit/Models/OrderTest.php index bc499be4..627e28d4 100644 --- a/tests/Unit/Models/OrderTest.php +++ b/tests/Unit/Models/OrderTest.php @@ -98,7 +98,7 @@ public function can_create_lines() OrderLine::factory()->create([ 'purchasable_type' => ProductVariant::class, 'purchasable_id' => ProductVariant::factory()->create()->id, - 'order_id' => $order->id, + 'order_id' => $order->id, ]); $this->assertCount(1, $order->refresh()->lines); @@ -161,12 +161,12 @@ public function can_retrieve_different_transaction_types_for_order() $charge = Transaction::factory()->create([ 'order_id' => $order->id, 'amount' => 200, - 'type' => 'capture', + 'type' => 'capture', ]); $refund = Transaction::factory()->create([ 'order_id' => $order->id, - 'type' => 'refund', + 'type' => 'refund', ]); $order = $order->refresh(); diff --git a/tests/Unit/Models/PriceTest.php b/tests/Unit/Models/PriceTest.php index 15321c81..139833c0 100644 --- a/tests/Unit/Models/PriceTest.php +++ b/tests/Unit/Models/PriceTest.php @@ -67,7 +67,7 @@ public function can_handle_non_int_values() $currencyGBP = Currency::factory()->create([ 'decimal_places' => 2, - 'code' => 'GBP', + 'code' => 'GBP', ]); $price = Price::factory()->create([ @@ -84,7 +84,7 @@ public function can_handle_non_int_values() $currencyUSD = Currency::factory()->create([ 'decimal_places' => 3, - 'code' => 'USD', + 'code' => 'USD', ]); $price = Price::factory()->create([ @@ -212,12 +212,12 @@ public function can_get_a_price() ]); Price::factory()->create([ - 'currency_id' => $currencyUSD->id, + 'currency_id' => $currencyUSD->id, 'customer_group_id' => $customerGroup->id, - 'priceable_id' => $variant->id, - 'priceable_type' => ProductVariant::class, - 'price' => 75, - 'tier' => 1, + 'priceable_id' => $variant->id, + 'priceable_type' => ProductVariant::class, + 'price' => 75, + 'tier' => 1, ]); // Check we get the default currency price diff --git a/tests/Unit/Models/ProductOptionTest.php b/tests/Unit/Models/ProductOptionTest.php index 407f907f..c1e107f1 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'; - $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 e173c96d..6e4eb5ef 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'; - $this->assertEquals($expected, (new Product)->searchableAs()); + $this->assertEquals($expected, (new Product())->searchableAs()); } /** @test */ diff --git a/tests/Unit/Observers/AddressObserverTest.php b/tests/Unit/Observers/AddressObserverTest.php index 004d7778..00d003ab 100644 --- a/tests/Unit/Observers/AddressObserverTest.php +++ b/tests/Unit/Observers/AddressObserverTest.php @@ -20,14 +20,14 @@ public function can_only_have_one_shipping_default_per_customer() $customer = Customer::factory()->create(); $addressA = Address::factory()->create([ - 'customer_id' => $customer->id, + 'customer_id' => $customer->id, 'shipping_default' => true, ]); $this->assertTrue($addressA->shipping_default); $addressB = Address::factory()->create([ - 'customer_id' => $customer->id, + 'customer_id' => $customer->id, 'shipping_default' => true, ]); @@ -48,14 +48,14 @@ public function can_only_have_one_billing_default_per_customer() $customer = Customer::factory()->create(); $addressA = Address::factory()->create([ - 'customer_id' => $customer->id, + 'customer_id' => $customer->id, 'billing_default' => true, ]); $this->assertTrue($addressA->billing_default); $addressB = Address::factory()->create([ - 'customer_id' => $customer->id, + 'customer_id' => $customer->id, 'billing_default' => true, ]); diff --git a/tests/Unit/Observers/OrderObserverTest.php b/tests/Unit/Observers/OrderObserverTest.php index 7301fa44..04823f3b 100644 --- a/tests/Unit/Observers/OrderObserverTest.php +++ b/tests/Unit/Observers/OrderObserverTest.php @@ -40,20 +40,20 @@ public function activity_is_logged_when_status_changes() 'status' => 'status-a', ]); - $this->assertDatabaseMissing((new Activity)->getTable(), [ + $this->assertDatabaseMissing((new Activity())->getTable(), [ 'subject_id' => $order->id, - 'event' => 'status-update', + 'event' => 'status-update', ]); $order->update([ 'status' => 'status-b', ]); - $this->assertDatabaseHas((new Activity)->getTable(), [ + $this->assertDatabaseHas((new Activity())->getTable(), [ 'subject_id' => $order->id, - 'event' => 'status-update', + 'event' => 'status-update', 'properties' => json_encode([ - 'new' => 'status-b', + 'new' => 'status-b', 'previous' => 'status-a', ]), ]); @@ -62,11 +62,11 @@ public function activity_is_logged_when_status_changes() 'status' => 'status-b', ]); - $this->assertDatabaseMissing((new Activity)->getTable(), [ + $this->assertDatabaseMissing((new Activity())->getTable(), [ 'subject_id' => $order->id, - 'event' => 'status-update', + 'event' => 'status-update', 'properties' => json_encode([ - 'new' => 'status-b', + 'new' => 'status-b', 'previous' => 'status-b', ]), ]); @@ -74,11 +74,11 @@ public function activity_is_logged_when_status_changes() $order->status = 'status-c'; $order->save(); - $this->assertDatabaseHas((new Activity)->getTable(), [ + $this->assertDatabaseHas((new Activity())->getTable(), [ 'subject_id' => $order->id, - 'event' => 'status-update', + 'event' => 'status-update', 'properties' => json_encode([ - 'new' => 'status-c', + 'new' => 'status-c', 'previous' => 'status-b', ]), ]); diff --git a/tests/Unit/Traits/HasUrlsTraitTest.php b/tests/Unit/Traits/HasUrlsTraitTest.php index 5443fdf1..20f0d3d2 100644 --- a/tests/Unit/Traits/HasUrlsTraitTest.php +++ b/tests/Unit/Traits/HasUrlsTraitTest.php @@ -25,9 +25,9 @@ public function urls_dont_generate_by_default() $this->assertCount(0, $product->refresh()->urls); - $this->assertDatabaseMissing((new Url)->getTable(), [ + $this->assertDatabaseMissing((new Url())->getTable(), [ 'element_type' => Product::class, - 'element_id' => $product->id, + 'element_id' => $product->id, ]); } @@ -42,10 +42,10 @@ public function can_generate_urls() $this->assertCount(1, $product->refresh()->urls); - $this->assertDatabaseHas((new Url)->getTable(), [ + $this->assertDatabaseHas((new Url())->getTable(), [ 'element_type' => Product::class, - 'element_id' => $product->id, - 'slug' => Str::slug($product->translateAttribute('name')), + 'element_id' => $product->id, + 'slug' => Str::slug($product->translateAttribute('name')), ]); } }