From 29a969601522e806714bee7cfa424c3e100f2267 Mon Sep 17 00:00:00 2001 From: Krzysztof Grabania Date: Sun, 16 Jun 2024 18:57:26 +0200 Subject: [PATCH] chore: fix laravel pint and phpstan errors --- src/Model/Builder/OrderBuilder.php | 18 +-- src/Model/Customer.php | 14 +-- src/Model/Item.php | 82 ++++++-------- src/Model/Meta/ItemMeta.php | 8 +- src/Model/Order.php | 80 +++++--------- src/Model/Product.php | 110 +++++++------------ src/Model/ProductAttribute.php | 46 ++++---- src/Model/ProductCategory.php | 2 +- src/Model/ProductTag.php | 2 +- src/Model/ProductType.php | 2 +- src/Support/Address.php | 30 ++--- src/Support/BillingAddress.php | 26 ++--- src/Support/Payment.php | 21 +--- src/Support/ShippingAddress.php | 22 ++-- src/Traits/AddressesTrait.php | 10 +- src/Traits/HasRelationsThroughMeta.php | 23 +--- src/WooCommerce.php | 4 - tests/TestCase.php | 14 +-- tests/Unit/Model/CustomerTest.php | 2 +- tests/Unit/Support/BillingAddressTest.php | 60 +++++----- tests/Unit/Support/PaymentTest.php | 8 +- tests/Unit/Support/ShippingAddressTest.php | 48 ++++---- tests/Unit/WooCommerceTest.php | 2 +- tests/database/factories/CustomerFactory.php | 16 +-- tests/database/factories/ItemFactory.php | 2 +- tests/database/factories/OrderFactory.php | 108 +++++++++--------- tests/database/factories/ProductFactory.php | 42 +++---- 27 files changed, 330 insertions(+), 472 deletions(-) diff --git a/src/Model/Builder/OrderBuilder.php b/src/Model/Builder/OrderBuilder.php index 3f11fba..d3438a7 100644 --- a/src/Model/Builder/OrderBuilder.php +++ b/src/Model/Builder/OrderBuilder.php @@ -10,8 +10,6 @@ class OrderBuilder extends PostBuilder { /** * Scope a query to only cancelled orders. - * - * @return \Corcel\Model\Builder\PostBuilder */ public function cancelled(): PostBuilder { @@ -20,8 +18,6 @@ public function cancelled(): PostBuilder /** * Scope a query to only completed orders. - * - * @return \Corcel\Model\Builder\PostBuilder */ public function completed(): PostBuilder { @@ -30,8 +26,6 @@ public function completed(): PostBuilder /** * Scope a query to only failed orders. - * - * @return \Corcel\Model\Builder\PostBuilder */ public function failed(): PostBuilder { @@ -40,8 +34,6 @@ public function failed(): PostBuilder /** * Scope a query to only on hold orders. - * - * @return \Corcel\Model\Builder\PostBuilder */ public function onHold(): PostBuilder { @@ -50,8 +42,6 @@ public function onHold(): PostBuilder /** * Scope a query to only pending orders. - * - * @return \Corcel\Model\Builder\PostBuilder */ public function pending(): PostBuilder { @@ -60,8 +50,6 @@ public function pending(): PostBuilder /** * Scope a query to only processing orders. - * - * @return \Corcel\Model\Builder\PostBuilder */ public function processing(): PostBuilder { @@ -70,8 +58,6 @@ public function processing(): PostBuilder /** * Scope a query to only refunded orders. - * - * @return \Corcel\Model\Builder\PostBuilder */ public function refunded(): PostBuilder { @@ -80,12 +66,10 @@ public function refunded(): PostBuilder /** * Scope a query to orders with given status. - * - * @return \Corcel\Model\Builder\PostBuilder */ public function status($status): PostBuilder { - $status = 'wc-' === substr($status, 0, 3) ? substr($status, 3) : $status; + $status = substr($status, 0, 3) === 'wc-' ? substr($status, 3) : $status; $builtin = [ 'cancelled', diff --git a/src/Model/Customer.php b/src/Model/Customer.php index d47c527..fef2a94 100644 --- a/src/Model/Customer.php +++ b/src/Model/Customer.php @@ -12,13 +12,13 @@ use Illuminate\Database\Eloquent\Relations\HasMany; /** - * @property int $order_count - * @property Collection $orders + * @property int $order_count + * @property Collection $orders */ class Customer extends User { - use HasFactory; use AddressesTrait; + use HasFactory; /** * @use HasRelationsThroughMeta<\Illuminate\Database\Eloquent\Model> @@ -26,9 +26,9 @@ class Customer extends User use HasRelationsThroughMeta; /** - * @inheritDoc + * {@inheritDoc} * - * @var array + * @var array */ protected $appends = [ 'order_count', @@ -46,8 +46,6 @@ protected static function newFactory() /** * Get order count attribute. - * - * @return int */ protected function getOrderCountAttribute(): int { @@ -59,7 +57,7 @@ protected function getOrderCountAttribute(): int /** * Get the related orders. * - * @return HasMany<\Illuminate\Database\Eloquent\Model> + * @return HasMany<\Illuminate\Database\Eloquent\Model> */ public function orders(): HasMany { diff --git a/src/Model/Item.php b/src/Model/Item.php index 8ec67e7..182e390 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -14,47 +14,47 @@ use Illuminate\Database\Eloquent\Relations\HasMany; /** - * @property int $id - * @property string $name - * @property string $type - * @property int $order_item_id - * @property string $order_item_name - * @property string $order_item_type - * @property int $order_id - * @property string|null $product_id - * @property string|null $variation_id - * @property string|null $quantity - * @property string|null $tax_class - * @property string|null $line_subtotal - * @property string|null $line_subtotal_tax - * @property string|null $line_total - * @property string|null $line_tax - * @property \Corcel\WooCommerce\Model\Order $order - * @property \Corcel\WooCommerce\Model\Product $product + * @property int $id + * @property string $name + * @property string $type + * @property int $order_item_id + * @property string $order_item_name + * @property string $order_item_type + * @property int $order_id + * @property string|null $product_id + * @property string|null $variation_id + * @property string|null $quantity + * @property string|null $tax_class + * @property string|null $line_subtotal + * @property string|null $line_subtotal_tax + * @property string|null $line_total + * @property string|null $line_tax + * @property \Corcel\WooCommerce\Model\Order $order + * @property \Corcel\WooCommerce\Model\Product $product */ class Item extends Model { - use HasFactory; use Aliases; + use HasFactory; use MetaFields; /** * The model aliases. * - * @var array|array> + * @var array|array> */ protected static $aliases = [ - 'id' => 'order_item_id', - 'name' => 'order_item_name', - 'type' => 'order_item_type', - 'product_id' => ['meta' => '_product_id'], + 'id' => 'order_item_id', + 'name' => 'order_item_name', + 'type' => 'order_item_type', + 'product_id' => ['meta' => '_product_id'], 'variation_id' => ['meta' => '_variation_id'], ]; /** - * @inheritDoc + * {@inheritDoc} * - * @var array + * @var array */ protected $appends = [ 'quantity', @@ -66,23 +66,23 @@ class Item extends Model ]; /** - * @inheritDoc + * {@inheritDoc} * - * @var string + * @var string */ protected $table = 'woocommerce_order_items'; /** - * @inheritDoc + * {@inheritDoc} * - * @var string + * @var string */ protected $primaryKey = 'order_item_id'; /** - * @inheritDoc + * {@inheritDoc} * - * @var bool + * @var bool */ public $timestamps = false; @@ -98,8 +98,6 @@ protected static function newFactory() /** * Get the line subtotal attribute. - * - * @return string|null */ protected function getLineSubtotalAttribute(): ?string { @@ -110,8 +108,6 @@ protected function getLineSubtotalAttribute(): ?string /** * Get the line subtotal tax attribute. - * - * @return string|null */ protected function getLineSubtotalTaxAttribute(): ?string { @@ -122,8 +118,6 @@ protected function getLineSubtotalTaxAttribute(): ?string /** * Get the line tax attribute. - * - * @return string|null */ protected function getLineTaxAttribute(): ?string { @@ -134,8 +128,6 @@ protected function getLineTaxAttribute(): ?string /** * Get the line total attribute. - * - * @return string|null */ protected function getLineTotalAttribute(): ?string { @@ -146,8 +138,6 @@ protected function getLineTotalAttribute(): ?string /** * Get the quantity attribute. - * - * @return string|null */ protected function getQuantityAttribute(): ?string { @@ -158,8 +148,6 @@ protected function getQuantityAttribute(): ?string /** * Get the tax class attribute. - * - * @return string|null */ protected function getTaxClassAttribute(): ?string { @@ -169,9 +157,9 @@ protected function getTaxClassAttribute(): ?string } /** - * @inheritDoc + * {@inheritDoc} * - * @return HasMany + * @return HasMany */ public function meta(): HasMany { @@ -181,7 +169,7 @@ public function meta(): HasMany /** * Get the related order. * - * @return BelongsTo + * @return BelongsTo */ public function order(): BelongsTo { @@ -191,7 +179,7 @@ public function order(): BelongsTo /** * Get the related product. * - * @return BelongsTo + * @return BelongsTo */ public function product(): BelongsTo { diff --git a/src/Model/Meta/ItemMeta.php b/src/Model/Meta/ItemMeta.php index 37e9cda..44ab273 100644 --- a/src/Model/Meta/ItemMeta.php +++ b/src/Model/Meta/ItemMeta.php @@ -9,16 +9,16 @@ class ItemMeta extends PostMeta { /** - * @inheritDoc + * {@inheritDoc} * - * @var string + * @var string */ protected $table = 'woocommerce_order_itemmeta'; /** - * @inheritDoc + * {@inheritDoc} * - * @var string[] + * @var string[] */ protected $fillable = [ 'order_item_id', diff --git a/src/Model/Order.php b/src/Model/Order.php index b6630bd..0af7ed2 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -18,39 +18,39 @@ use Illuminate\Database\Eloquent\Relations\HasMany; /** - * @property int|null $customer_id - * @property string|null $currency - * @property string|null $total - * @property string|null $shipping - * @property string|null $tax - * @property string|null $shipping_tax - * @property string $status - * @property Carbon|null $date_completed - * @property Carbon|null $date_paid - * @property Payment $payment - * @property Customer|null $customer - * @property Collection $items + * @property int|null $customer_id + * @property string|null $currency + * @property string|null $total + * @property string|null $shipping + * @property string|null $tax + * @property string|null $shipping_tax + * @property string $status + * @property Carbon|null $date_completed + * @property Carbon|null $date_paid + * @property Payment $payment + * @property Customer|null $customer + * @property Collection $items */ class Order extends Post { - use HasFactory; - use Aliases; use AddressesTrait; + use Aliases; + use HasFactory; use MetaFields; /** * The model aliases. * - * @var array> + * @var array> */ protected static $aliases = [ 'customer_id' => ['meta' => '_customer_user'], ]; /** - * @inheritDoc + * {@inheritDoc} * - * @var array + * @var array */ protected $appends = [ 'currency', @@ -67,7 +67,7 @@ class Order extends Post /** * The post type slug. * - * @var string + * @var string */ protected $postType = 'shop_order'; @@ -82,7 +82,7 @@ protected static function newFactory() } /** - * @inheritDoc + * {@inheritDoc} */ public function newEloquentBuilder($builder): OrderBuilder { @@ -91,8 +91,6 @@ public function newEloquentBuilder($builder): OrderBuilder /** * Get the currency attribute. - * - * @return string|null */ protected function getCurrencyAttribute(): ?string { @@ -103,8 +101,6 @@ protected function getCurrencyAttribute(): ?string /** * Get the total attribute. - * - * @return string|null */ protected function getTotalAttribute(): ?string { @@ -115,8 +111,6 @@ protected function getTotalAttribute(): ?string /** * Get the shipping attribute. - * - * @return string|null */ protected function getShippingAttribute(): ?string { @@ -127,8 +121,6 @@ protected function getShippingAttribute(): ?string /** * Get the tax attribute. - * - * @return string|null */ protected function getTaxAttribute(): ?string { @@ -139,8 +131,6 @@ protected function getTaxAttribute(): ?string /** * Get the shipping tax attribute. - * - * @return string|null */ protected function getShippingTaxAttribute(): ?string { @@ -151,20 +141,16 @@ protected function getShippingTaxAttribute(): ?string /** * Get the status attribute. - * - * @return string */ public function getStatusAttribute(): string { $status = $this->post_status; // @phpstan-ignore-line - return 'wc-' === substr($status, 0, 3) ? substr($status, 3) : $status; + return substr($status, 0, 3) === 'wc-' ? substr($status, 3) : $status; } /** * Get the completed date attribute. - * - * @return Carbon|null */ protected function getDateCompletedAttribute(): ?Carbon { @@ -180,19 +166,13 @@ protected function getDateCompletedAttribute(): ?Carbon */ $value = $this->getMeta('_completed_date'); - if (is_string($value)) { - $datetime = Carbon::createFromFormat('Y-m-d H:i:s', $value); - - return $datetime !== false ? $datetime : null; - } - - return null; + return is_string($value) + ? Carbon::createFromFormat('Y-m-d H:i:s', $value) + : null; } /** * Get the paid date attribute. - * - * @return Carbon|null */ public function getDatePaidAttribute(): ?Carbon { @@ -208,19 +188,13 @@ public function getDatePaidAttribute(): ?Carbon */ $value = $this->getMeta('_paid_date'); - if (is_string($value)) { - $datetime = Carbon::createFromFormat('Y-m-d H:i:s', $value); - - return $datetime !== false ? $datetime : null; - } - - return null; + return is_string($value) + ? Carbon::createFromFormat('Y-m-d H:i:s', $value) + : null; } /** * Get the payment attribute. - * - * @return Payment */ public function getPaymentAttribute(): Payment { @@ -240,7 +214,7 @@ public function customer(): BelongsTo /** * Get related items. * - * @return HasMany + * @return HasMany */ public function items(): HasMany { diff --git a/src/Model/Product.php b/src/Model/Product.php index c36e218..da61e13 100644 --- a/src/Model/Product.php +++ b/src/Model/Product.php @@ -18,53 +18,53 @@ use Illuminate\Support\Str; /** - * @property string|null $price - * @property string|null $regular_price - * @property string|null $sale_price - * @property bool $on_sale - * @property string|null $sku - * @property string|null $tax_status - * @property bool $is_taxable - * @property string|null $weight - * @property string|null $length - * @property string|null $width - * @property string|null $height - * @property bool $is_virtual - * @property bool $is_downloadable - * @property string|null $stock - * @property bool $in_stock - * @property string|null $type - * @property BaseCollection $attributes - * @property Collection $crosssells - * @property Collection $upsells - * @property BaseCollection $gallery - * @property Collection $categories - * @property Collection $items - * @property Collection $productTypes - * @property Collection $tags + * @property string|null $price + * @property string|null $regular_price + * @property string|null $sale_price + * @property bool $on_sale + * @property string|null $sku + * @property string|null $tax_status + * @property bool $is_taxable + * @property string|null $weight + * @property string|null $length + * @property string|null $width + * @property string|null $height + * @property bool $is_virtual + * @property bool $is_downloadable + * @property string|null $stock + * @property bool $in_stock + * @property string|null $type + * @property BaseCollection $attributes + * @property Collection $crosssells + * @property Collection $upsells + * @property BaseCollection $gallery + * @property Collection $categories + * @property Collection $items + * @property Collection $productTypes + * @property Collection $tags */ class Product extends Post { - use HasFactory; use Aliases; - use MetaFields; - + use HasFactory; /** * @use HasRelationsThroughMeta<\Illuminate\Database\Eloquent\Model> */ use HasRelationsThroughMeta; + use MetaFields; + /** * Preloaded product attributes list. * - * @var Collection + * @var Collection */ protected static $productAttributes; /** - * @inheritDoc + * {@inheritDoc} * - * @var array + * @var array */ protected $appends = [ 'price', @@ -86,12 +86,12 @@ class Product extends Post /** * The post type of model. * - * @var string + * @var string */ protected $postType = 'product'; /** - * @inheritDoc + * {@inheritDoc} */ protected static function boot() { @@ -112,8 +112,6 @@ protected static function newFactory() /** * Get the price attribute. - * - * @return string|null */ protected function getPriceAttribute(): ?string { @@ -124,8 +122,6 @@ protected function getPriceAttribute(): ?string /** * Get the regular price attribute. - * - * @return string|null */ protected function getRegularPriceAttribute(): ?string { @@ -136,8 +132,6 @@ protected function getRegularPriceAttribute(): ?string /** * Get the sale price attribute - * - * @return string|null */ protected function getSalePriceAttribute(): ?string { @@ -148,8 +142,6 @@ protected function getSalePriceAttribute(): ?string /** * Get the on sale attribute - * - * @return bool */ protected function getOnSaleAttribute(): bool { @@ -158,8 +150,6 @@ protected function getOnSaleAttribute(): bool /** * Get the SKU attribute. - * - * @return string|null */ protected function getSkuAttribute(): ?string { @@ -170,8 +160,6 @@ protected function getSkuAttribute(): ?string /** * Get the tax status attribute. - * - * @return string|null */ protected function getTaxStatusAttribute(): ?string { @@ -182,18 +170,14 @@ protected function getTaxStatusAttribute(): ?string /** * Get the is taxable attribute. - * - * @return bool */ public function getIsTaxableAttribute(): bool { - return 'taxable' === $this->tax_status; + return $this->tax_status === 'taxable'; } /** * Get the weight attribute. - * - * @return string|null */ protected function getWeightAttribute(): ?string { @@ -204,8 +188,6 @@ protected function getWeightAttribute(): ?string /** * Get the length attribute. - * - * @return string|null */ protected function getLengthAttribute(): ?string { @@ -216,8 +198,6 @@ protected function getLengthAttribute(): ?string /** * Get the width attribute. - * - * @return string|null */ protected function getWidthAttribute(): ?string { @@ -228,8 +208,6 @@ protected function getWidthAttribute(): ?string /** * Get the height attribute. - * - * @return string|null */ protected function getHeightAttribute(): ?string { @@ -240,28 +218,22 @@ protected function getHeightAttribute(): ?string /** * Get the is virtual attribute. - * - * @return bool */ protected function getIsVirtualAttribute(): bool { - return 'yes' === $this->getMeta('_virtual'); + return $this->getMeta('_virtual') === 'yes'; } /** * Get the is downloadable attribute. - * - * @return bool */ protected function getIsDownloadableAttribute(): bool { - return 'yes' === $this->getMeta('_downloadable'); + return $this->getMeta('_downloadable') === 'yes'; } /** * Get the stock attribute. - * - * @return string|null */ protected function getStockAttribute(): ?string { @@ -272,18 +244,16 @@ protected function getStockAttribute(): ?string /** * Get the in stock attribute. - * - * @return bool */ protected function getInStockAttribute(): bool { - return 'instock' === $this->getMeta('_stock_status'); + return $this->getMeta('_stock_status') === 'instock'; } /** * Get the product attributes attribute. * - * @return BaseCollection + * @return BaseCollection */ protected function getAttributesAttribute(): BaseCollection { @@ -378,8 +348,6 @@ public function getGalleryAttribute(): BaseCollection /** * Get the type attribute. - * - * @return string|null */ protected function getTypeAttribute(): ?string { @@ -392,7 +360,7 @@ protected function getTypeAttribute(): ?string /** * Get the related categories. * - * @return BelongsToMany + * @return BelongsToMany */ public function categories(): BelongsToMany { @@ -407,7 +375,7 @@ public function categories(): BelongsToMany /** * Get the related items. * - * @return HasMany<\Illuminate\Database\Eloquent\Model> + * @return HasMany<\Illuminate\Database\Eloquent\Model> */ public function items(): HasMany { diff --git a/src/Model/ProductAttribute.php b/src/Model/ProductAttribute.php index 6bb6df3..ceb921e 100644 --- a/src/Model/ProductAttribute.php +++ b/src/Model/ProductAttribute.php @@ -9,18 +9,18 @@ use Illuminate\Support\Collection; /** - * @property string|null $id - * @property string|null $slug - * @property string|null $name - * @property string|null $type - * @property string|null $order_by - * @property bool|null $public - * @property string|null $attribute_id - * @property string|null $attribute_name - * @property string|null $attribute_label - * @property string|null $attribute_type - * @property string|null $attribute_order_by - * @property bool|null $attribute_public + * @property string|null $id + * @property string|null $slug + * @property string|null $name + * @property string|null $type + * @property string|null $order_by + * @property bool|null $public + * @property string|null $attribute_id + * @property string|null $attribute_name + * @property string|null $attribute_label + * @property string|null $attribute_type + * @property string|null $attribute_order_by + * @property bool|null $attribute_public */ class ProductAttribute extends Model { @@ -29,40 +29,40 @@ class ProductAttribute extends Model /** * The terms collection. * - * @var Collection + * @var Collection */ public Collection $terms; /** * The model aliases. * - * @var array + * @var array */ protected static $aliases = [ - 'id' => 'attribute_id', - 'slug' => 'attribute_name', - 'name' => 'attribute_label', - 'type' => 'attribute_type', + 'id' => 'attribute_id', + 'slug' => 'attribute_name', + 'name' => 'attribute_label', + 'type' => 'attribute_type', 'order_by' => 'attribute_orderby', - 'public' => 'attribute_public', + 'public' => 'attribute_public', ]; /** - * @inheritDoc + * {@inheritDoc} * - * @var array + * @var array */ protected $casts = [ 'attribute_public' => 'bool', ]; /** - * @inheritDoc + * {@inheritDoc} */ protected $primaryKey = 'attribute_id'; /** - * @inheritDoc + * {@inheritDoc} */ protected $table = 'woocommerce_attribute_taxonomies'; diff --git a/src/Model/ProductCategory.php b/src/Model/ProductCategory.php index 56456ab..7a76222 100644 --- a/src/Model/ProductCategory.php +++ b/src/Model/ProductCategory.php @@ -11,7 +11,7 @@ class ProductCategory extends Taxonomy /** * The taxonomy slug. * - * @var string + * @var string */ protected $taxonomy = 'product_cat'; } diff --git a/src/Model/ProductTag.php b/src/Model/ProductTag.php index 3621496..9dd7b6f 100644 --- a/src/Model/ProductTag.php +++ b/src/Model/ProductTag.php @@ -11,7 +11,7 @@ class ProductTag extends Taxonomy /** * The taxonomy slug. * - * @var string + * @var string */ protected $taxonomy = 'product_tag'; } diff --git a/src/Model/ProductType.php b/src/Model/ProductType.php index c368670..115da0e 100644 --- a/src/Model/ProductType.php +++ b/src/Model/ProductType.php @@ -11,7 +11,7 @@ class ProductType extends Taxonomy /** * The taxonomy slug. * - * @var string + * @var string */ protected $taxonomy = 'product_type'; } diff --git a/src/Support/Address.php b/src/Support/Address.php index ed4c11b..ff28dd0 100644 --- a/src/Support/Address.php +++ b/src/Support/Address.php @@ -18,30 +18,23 @@ class Address implements Arrayable, Jsonable { /** * The model instance. - * - * @var Model */ protected Model $model; /** * The address type. - * - * @var string */ protected string $type; /** * The address attributes. * - * @var array + * @var array */ protected array $attributes = []; /** * The address constructor. - * - * @param Model $model - * @param string $type */ public function __construct(Model $model, string $type) { @@ -53,8 +46,6 @@ public function __construct(Model $model, string $type) /** * Parse address attributes. - * - * @return void */ protected function parseAttributes(): void { @@ -69,7 +60,7 @@ protected function parseAttributes(): void /** * List of the attribute keys. * - * @return array + * @return array */ protected function attributeKeys(): array { @@ -97,9 +88,6 @@ protected function attributeKeys(): array /** * Get meta key for given attribute name. - * - * @param string $key - * @return string */ protected function getMetaKey(string $key): string { @@ -110,8 +98,6 @@ protected function getMetaKey(string $key): string /** * Get meta key pattern based on model. - * - * @return string */ protected function metaKeyPattern(): string { @@ -128,9 +114,9 @@ protected function metaKeyPattern(): string } /** - * @inheritDoc + * {@inheritDoc} * - * @return array + * @return array */ public function toArray(): array { @@ -138,16 +124,15 @@ public function toArray(): array } /** - * @inheritDoc + * {@inheritDoc} * * @param int $options - * @return string */ public function toJson($options = 0): string { $json = json_encode($this->toArray(), $options); - if ($json === false || JSON_ERROR_NONE !== json_last_error()) { + if ($json === false || json_last_error() !== JSON_ERROR_NONE) { throw new InvalidArgumentException('An error occured while converting order address to JSON.'); } @@ -157,8 +142,7 @@ public function toJson($options = 0): string /** * Magic method to get address attributes. * - * @param string $key - * @return mixed + * @return mixed */ public function __get(string $key) { diff --git a/src/Support/BillingAddress.php b/src/Support/BillingAddress.php index 2db14d9..b8f7f15 100644 --- a/src/Support/BillingAddress.php +++ b/src/Support/BillingAddress.php @@ -7,24 +7,22 @@ use Corcel\Model; /** - * @property string|null $first_name - * @property string|null $last_name - * @property string|null $company - * @property string|null $address_1 - * @property string|null $address_2 - * @property string|null $city - * @property string|null $state - * @property string|null $postcode - * @property string|null $country - * @property string|null $email - * @property string|null $phone + * @property string|null $first_name + * @property string|null $last_name + * @property string|null $company + * @property string|null $address_1 + * @property string|null $address_2 + * @property string|null $city + * @property string|null $state + * @property string|null $postcode + * @property string|null $country + * @property string|null $email + * @property string|null $phone */ class BillingAddress extends Address { /** - * @inheritDoc - * - * @param Model $model + * {@inheritDoc} */ public function __construct(Model $model) { diff --git a/src/Support/Payment.php b/src/Support/Payment.php index 0832e9c..f05a81b 100644 --- a/src/Support/Payment.php +++ b/src/Support/Payment.php @@ -16,29 +16,21 @@ class Payment implements Arrayable, Jsonable { /** * The payment method. - * - * @var string|null */ public ?string $method = null; /** * The payment method title. - * - * @var string|null */ public ?string $method_title = null; /** * The payment transation identificator. - * - * @var string|null */ public ?string $transaction_id = null; /** * The payment constructor. - * - * @param Order $order */ public function __construct(Order $order) { @@ -52,30 +44,29 @@ public function __construct(Order $order) } /** - * @inheritDoc + * {@inheritDoc} * - * @return array + * @return array */ public function toArray(): array { return [ - 'method' => $this->method, - 'method_title' => $this->method_title, + 'method' => $this->method, + 'method_title' => $this->method_title, 'transaction_id' => $this->transaction_id, ]; } /** - * @inheritDoc + * {@inheritDoc} * * @param int $options - * @return string */ public function toJson($options = 0): string { $json = json_encode($this->toArray(), $options); - if ($json === false || JSON_ERROR_NONE !== json_last_error()) { + if ($json === false || json_last_error() !== JSON_ERROR_NONE) { throw new InvalidArgumentException('An error occured while converting order payment to JSON.'); } diff --git a/src/Support/ShippingAddress.php b/src/Support/ShippingAddress.php index 04c79bf..98824c9 100644 --- a/src/Support/ShippingAddress.php +++ b/src/Support/ShippingAddress.php @@ -7,22 +7,20 @@ use Corcel\Model; /** - * @property string|null $first_name - * @property string|null $last_name - * @property string|null $company - * @property string|null $address_1 - * @property string|null $address_2 - * @property string|null $city - * @property string|null $state - * @property string|null $postcode - * @property string|null $country + * @property string|null $first_name + * @property string|null $last_name + * @property string|null $company + * @property string|null $address_1 + * @property string|null $address_2 + * @property string|null $city + * @property string|null $state + * @property string|null $postcode + * @property string|null $country */ class ShippingAddress extends Address { /** - * @inheritDoc - * - * @param Model $model + * {@inheritDoc} */ public function __construct(Model $model) { diff --git a/src/Traits/AddressesTrait.php b/src/Traits/AddressesTrait.php index 00b0d29..74a275c 100644 --- a/src/Traits/AddressesTrait.php +++ b/src/Traits/AddressesTrait.php @@ -8,15 +8,13 @@ use Corcel\WooCommerce\Support\ShippingAddress; /** - * @property \Corcel\WooCommerce\Support\BillingAddress $billing_address - * @property \Corcel\WooCommerce\Support\ShippingAddress $shipping_address + * @property \Corcel\WooCommerce\Support\BillingAddress $billing_address + * @property \Corcel\WooCommerce\Support\ShippingAddress $shipping_address */ trait AddressesTrait { /** * Initialize trait. - * - * @return void */ protected function initializeAddressesTrait(): void { @@ -28,8 +26,6 @@ protected function initializeAddressesTrait(): void /** * Get the billing address attribute. - * - * @return \Corcel\WooCommerce\Support\BillingAddress */ protected function getBillingAddressAttribute(): BillingAddress { @@ -38,8 +34,6 @@ protected function getBillingAddressAttribute(): BillingAddress /** * Get the shipping address attribute. - * - * @return \Corcel\WooCommerce\Support\ShippingAddress */ protected function getShippingAddressAttribute(): ShippingAddress { diff --git a/src/Traits/HasRelationsThroughMeta.php b/src/Traits/HasRelationsThroughMeta.php index 8f84761..7d4a6b8 100644 --- a/src/Traits/HasRelationsThroughMeta.php +++ b/src/Traits/HasRelationsThroughMeta.php @@ -21,16 +21,12 @@ trait HasRelationsThroughMeta /** * Define a one-to-many relation through meta. * - * @param string $related - * @param string $metaKey - * @param string|null $foreignKey - * @param string|null $localKey - * @return HasMany + * @return HasMany * - * @throws InvalidArgumentException - * @throws LogicException + * @throws InvalidArgumentException + * @throws LogicException */ - public function hasManyThroughMeta(string $related, string $metaKey, string $foreignKey = null, string $localKey = null): HasMany + public function hasManyThroughMeta(string $related, string $metaKey, ?string $foreignKey = null, ?string $localKey = null): HasMany { /** @var Model */ $model = $this->newRelatedInstance($related); @@ -51,11 +47,9 @@ public function hasManyThroughMeta(string $related, string $metaKey, string $for /** * Make meta model instance. * - * @param \Illuminate\Database\Eloquent\Model $model - * @return \Corcel\Model\Meta\Meta * - * @throws InvalidArgumentException - * @throws LogicException + * @throws InvalidArgumentException + * @throws LogicException */ private function metaInstance(Model $model): Meta { @@ -82,11 +76,6 @@ private function metaInstance(Model $model): Meta /** * Build join clause between model and meta tables. - * - * @param string $localKey - * @param string $foreignKey - * @param string $metaKey - * @return Closure */ private function joinClause(string $localKey, string $foreignKey, string $metaKey): Closure { diff --git a/src/WooCommerce.php b/src/WooCommerce.php index 632a029..2f793be 100644 --- a/src/WooCommerce.php +++ b/src/WooCommerce.php @@ -10,15 +10,11 @@ class WooCommerce { /** * The shop currency. - * - * @var string|null */ private static ?string $currency = null; /** * Get the shop currency. - * - * @return string|null */ public static function currency(): ?string { diff --git a/tests/TestCase.php b/tests/TestCase.php index a5aec0a..31807b5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -9,9 +9,7 @@ class TestCase extends BaseTestCase { /** - * @inheritDoc - * - * @return void + * {@inheritDoc} */ public function setUp(): void { @@ -20,15 +18,14 @@ public function setUp(): void $this->loadMigrationsFrom([ '--database' => 'wp', '--realpath' => true, - '--path' => __DIR__.'/database/migrations', + '--path' => __DIR__.'/database/migrations', ]); } /** - * @inheritDoc + * {@inheritDoc} * * @param \Illuminate\Foundation\Application $app - * @return void */ protected function getEnvironmentSetUp($app): void { @@ -39,14 +36,13 @@ protected function getEnvironmentSetUp($app): void * Configure database. * * @param \Illuminate\Foundation\Application $app - * @return void */ private function configureDatabaseConfig($app): void { $app['config']->set('database.connections.wp', [ - 'driver' => 'sqlite', + 'driver' => 'sqlite', 'database' => ':memory:', - 'prefix' => 'wp_', + 'prefix' => 'wp_', ]); $app['config']->set('database.default', 'wp'); diff --git a/tests/Unit/Model/CustomerTest.php b/tests/Unit/Model/CustomerTest.php index c9fee08..274699c 100644 --- a/tests/Unit/Model/CustomerTest.php +++ b/tests/Unit/Model/CustomerTest.php @@ -41,7 +41,7 @@ public function testRelatedOrders(): void $order = Order::factory()->create(); $order->createMeta('_customer_user', $customer->ID); - $this->assertSame(2, $customer->orders()->count()); // @phpstan-ignore-line + $this->assertSame(2, $customer->orders()->count()); } private function createCustomer(): Customer diff --git a/tests/Unit/Support/BillingAddressTest.php b/tests/Unit/Support/BillingAddressTest.php index b8ecd6c..79c9593 100644 --- a/tests/Unit/Support/BillingAddressTest.php +++ b/tests/Unit/Support/BillingAddressTest.php @@ -14,30 +14,30 @@ class BillingAddressTest extends TestCase { private const ORDER_META_FIELDS = [ '_billing_first_name' => 'John', - '_billing_last_name' => 'Doe', - '_billing_company' => 'ACME corp.', - '_billing_address_1' => 'Example Street 10', - '_billing_address_2' => 'Test Address', - '_billing_city' => 'Los Angeles', - '_billing_state' => 'California', - '_billing_postcode' => '00000', - '_billing_country' => 'USA', - '_billing_email' => 'john@doe.com', - '_billing_phone' => '00-00-000-000', + '_billing_last_name' => 'Doe', + '_billing_company' => 'ACME corp.', + '_billing_address_1' => 'Example Street 10', + '_billing_address_2' => 'Test Address', + '_billing_city' => 'Los Angeles', + '_billing_state' => 'California', + '_billing_postcode' => '00000', + '_billing_country' => 'USA', + '_billing_email' => 'john@doe.com', + '_billing_phone' => '00-00-000-000', ]; private const CUSTOMER_META_FIELDS = [ 'billing_first_name' => 'John', - 'billing_last_name' => 'Doe', - 'billing_company' => 'ACME corp.', - 'billing_address_1' => 'Example Street 10', - 'billing_address_2' => 'Test Address', - 'billing_city' => 'Los Angeles', - 'billing_state' => 'California', - 'billing_postcode' => '00000', - 'billing_country' => 'USA', - 'billing_email' => 'john@doe.com', - 'billing_phone' => '00-00-000-000', + 'billing_last_name' => 'Doe', + 'billing_company' => 'ACME corp.', + 'billing_address_1' => 'Example Street 10', + 'billing_address_2' => 'Test Address', + 'billing_city' => 'Los Angeles', + 'billing_state' => 'California', + 'billing_postcode' => '00000', + 'billing_country' => 'USA', + 'billing_email' => 'john@doe.com', + 'billing_phone' => '00-00-000-000', ]; public function testOrderBillingAddressProperties(): void @@ -80,16 +80,16 @@ public function testToArrayMethod(): void $array = [ 'first_name' => 'John', - 'last_name' => 'Doe', - 'company' => 'ACME corp.', - 'address_1' => 'Example Street 10', - 'address_2' => 'Test Address', - 'city' => 'Los Angeles', - 'state' => 'California', - 'postcode' => '00000', - 'country' => 'USA', - 'email' => 'john@doe.com', - 'phone' => '00-00-000-000', + 'last_name' => 'Doe', + 'company' => 'ACME corp.', + 'address_1' => 'Example Street 10', + 'address_2' => 'Test Address', + 'city' => 'Los Angeles', + 'state' => 'California', + 'postcode' => '00000', + 'country' => 'USA', + 'email' => 'john@doe.com', + 'phone' => '00-00-000-000', ]; $this->assertSame($array, $billingAddress->toArray()); diff --git a/tests/Unit/Support/PaymentTest.php b/tests/Unit/Support/PaymentTest.php index 6d3abf1..c323bfc 100644 --- a/tests/Unit/Support/PaymentTest.php +++ b/tests/Unit/Support/PaymentTest.php @@ -24,8 +24,8 @@ public function testToArrayMethod(): void { $payment = $this->createPayment(); $array = [ - 'method' => 'test', - 'method_title' => 'Test', + 'method' => 'test', + 'method_title' => 'Test', 'transaction_id' => 'tid-000', ]; @@ -64,9 +64,9 @@ private function createPayment(): Payment /** @var Order */ $order = Order::factory()->create(); $order->createMeta([ - '_payment_method' => 'test', + '_payment_method' => 'test', '_payment_method_title' => 'Test', - '_transaction_id' => 'tid-000', + '_transaction_id' => 'tid-000', ]); return new Payment($order); diff --git a/tests/Unit/Support/ShippingAddressTest.php b/tests/Unit/Support/ShippingAddressTest.php index be0e71c..fe0809e 100644 --- a/tests/Unit/Support/ShippingAddressTest.php +++ b/tests/Unit/Support/ShippingAddressTest.php @@ -14,26 +14,26 @@ class ShippingAddressTest extends TestCase { private const ORDER_META_FIELDS = [ '_shipping_first_name' => 'John', - '_shipping_last_name' => 'Doe', - '_shipping_company' => 'ACME corp.', - '_shipping_address_1' => 'Example Street 10', - '_shipping_address_2' => 'Test Address', - '_shipping_city' => 'Los Angeles', - '_shipping_state' => 'California', - '_shipping_postcode' => '00000', - '_shipping_country' => 'USA', + '_shipping_last_name' => 'Doe', + '_shipping_company' => 'ACME corp.', + '_shipping_address_1' => 'Example Street 10', + '_shipping_address_2' => 'Test Address', + '_shipping_city' => 'Los Angeles', + '_shipping_state' => 'California', + '_shipping_postcode' => '00000', + '_shipping_country' => 'USA', ]; private const CUSTOMER_META_FIELDS = [ 'shipping_first_name' => 'John', - 'shipping_last_name' => 'Doe', - 'shipping_company' => 'ACME corp.', - 'shipping_address_1' => 'Example Street 10', - 'shipping_address_2' => 'Test Address', - 'shipping_city' => 'Los Angeles', - 'shipping_state' => 'California', - 'shipping_postcode' => '00000', - 'shipping_country' => 'USA', + 'shipping_last_name' => 'Doe', + 'shipping_company' => 'ACME corp.', + 'shipping_address_1' => 'Example Street 10', + 'shipping_address_2' => 'Test Address', + 'shipping_city' => 'Los Angeles', + 'shipping_state' => 'California', + 'shipping_postcode' => '00000', + 'shipping_country' => 'USA', ]; public function testOrderShippingAddressProperties(): void @@ -72,14 +72,14 @@ public function testToArrayMethod(): void $array = [ 'first_name' => 'John', - 'last_name' => 'Doe', - 'company' => 'ACME corp.', - 'address_1' => 'Example Street 10', - 'address_2' => 'Test Address', - 'city' => 'Los Angeles', - 'state' => 'California', - 'postcode' => '00000', - 'country' => 'USA', + 'last_name' => 'Doe', + 'company' => 'ACME corp.', + 'address_1' => 'Example Street 10', + 'address_2' => 'Test Address', + 'city' => 'Los Angeles', + 'state' => 'California', + 'postcode' => '00000', + 'country' => 'USA', ]; $this->assertSame($array, $shippingAddress->toArray()); diff --git a/tests/Unit/WooCommerceTest.php b/tests/Unit/WooCommerceTest.php index a0544f1..bd37704 100644 --- a/tests/Unit/WooCommerceTest.php +++ b/tests/Unit/WooCommerceTest.php @@ -13,7 +13,7 @@ class WooCommerceTest extends TestCase public function testShopCurrency(): void { DB::table('options')->insert([ - 'option_name' => 'woocommerce_currency', + 'option_name' => 'woocommerce_currency', 'option_value' => 'EUR', ]); diff --git a/tests/database/factories/CustomerFactory.php b/tests/database/factories/CustomerFactory.php index dde1331..818ab11 100644 --- a/tests/database/factories/CustomerFactory.php +++ b/tests/database/factories/CustomerFactory.php @@ -25,15 +25,15 @@ public function definition() $name = $this->faker->firstName; return [ - 'user_login' => Str::lower(Str::ascii($name)), - 'user_pass' => bcrypt('secret'), - 'user_nicename' => $name, - 'user_email' => $this->faker->email, - 'user_url' => $this->faker->url, - 'user_registered' => $this->faker->dateTime, + 'user_login' => Str::lower(Str::ascii($name)), + 'user_pass' => bcrypt('secret'), + 'user_nicename' => $name, + 'user_email' => $this->faker->email, + 'user_url' => $this->faker->url, + 'user_registered' => $this->faker->dateTime, 'user_activation_key' => Str::random(10), - 'user_status' => 0, - 'display_name' => $name, + 'user_status' => 0, + 'display_name' => $name, ]; } } diff --git a/tests/database/factories/ItemFactory.php b/tests/database/factories/ItemFactory.php index aa3d446..39a8c8f 100644 --- a/tests/database/factories/ItemFactory.php +++ b/tests/database/factories/ItemFactory.php @@ -24,7 +24,7 @@ public function definition() return [ 'order_item_name' => $this->faker->words(mt_rand(2, 4), true), 'order_item_type' => $this->faker->randomElement(['line_item', 'tax', 'coupon']), - 'order_id' => $this->faker->numberBetween(1, 10000), + 'order_id' => $this->faker->numberBetween(1, 10000), ]; } } diff --git a/tests/database/factories/OrderFactory.php b/tests/database/factories/OrderFactory.php index 552ce43..8766e1c 100644 --- a/tests/database/factories/OrderFactory.php +++ b/tests/database/factories/OrderFactory.php @@ -27,35 +27,35 @@ public function definition() $createdAtGMT = $createdAt->setTimezone(new DateTimeZone('UTC')); return [ - 'post_author' => $this->faker->numberBetween(1, 100), - 'post_date' => $createdAt->format('Y-m-d H:i:s'), - 'post_date_gmt' => $createdAtGMT->format('Y-m-d H:i:s'), - 'post_content' => '', - 'post_title' => sprintf('Order – %s', $createdAt->format('F j, Y @ h:i A')), - 'post_excerpt' => '', - 'post_status' => 'wc-completed', - 'comment_status' => 'closed', - 'ping_status' => 'closed', - 'post_password' => '', - 'post_name' => '', - 'to_ping' => '', - 'pinged' => '', - 'post_modified' => $createdAt->format('Y-m-d H:i:s'), - 'post_modified_gmt' => $createdAtGMT->format('Y-m-d H:i:s'), + 'post_author' => $this->faker->numberBetween(1, 100), + 'post_date' => $createdAt->format('Y-m-d H:i:s'), + 'post_date_gmt' => $createdAtGMT->format('Y-m-d H:i:s'), + 'post_content' => '', + 'post_title' => sprintf('Order – %s', $createdAt->format('F j, Y @ h:i A')), + 'post_excerpt' => '', + 'post_status' => 'wc-completed', + 'comment_status' => 'closed', + 'ping_status' => 'closed', + 'post_password' => '', + 'post_name' => '', + 'to_ping' => '', + 'pinged' => '', + 'post_modified' => $createdAt->format('Y-m-d H:i:s'), + 'post_modified_gmt' => $createdAtGMT->format('Y-m-d H:i:s'), 'post_content_filtered' => '', - 'post_parent' => 0, - 'guid' => 'http://woocommerce.example/?post_type=shop_order&p=1', - 'menu_order' => 0, - 'post_type' => 'shop_order', - 'post_mime_type' => '', - 'comment_count' => 0, + 'post_parent' => 0, + 'guid' => 'http://woocommerce.example/?post_type=shop_order&p=1', + 'menu_order' => 0, + 'post_type' => 'shop_order', + 'post_mime_type' => '', + 'comment_count' => 0, ]; } /** * Applies pending state to model. * - * @return Factory + * @return Factory */ public function pending(): Factory { @@ -65,7 +65,7 @@ public function pending(): Factory /** * Applies cancelling state to model. * - * @return Factory + * @return Factory */ public function cancelled(): Factory { @@ -75,7 +75,7 @@ public function cancelled(): Factory /** * Applies refunded state to model. * - * @return Factory + * @return Factory */ public function refunded(): Factory { @@ -85,27 +85,27 @@ public function refunded(): Factory /** * Applies withMeta state to model. * - * @return Factory + * @return Factory */ public function withMeta(): Factory { return $this->afterCreating(function (Order $order) { $order->createMeta([ - '_order_currency' => $this->faker->currencyCode, - '_order_total' => $this->faker->randomFloat(2, 0, 200), - '_order_tax' => $this->faker->randomFloat(2, 0, 200), - '_date_completed' => $this->faker->dateTime->format('Y-m-d H:i:s'), + '_order_currency' => $this->faker->currencyCode, + '_order_total' => $this->faker->randomFloat(2, 0, 200), + '_order_tax' => $this->faker->randomFloat(2, 0, 200), + '_date_completed' => $this->faker->dateTime->format('Y-m-d H:i:s'), '_billing_first_name' => $this->faker->firstName, - '_billing_last_name' => $this->faker->lastName, - '_billing_company' => $this->faker->optional()->company, - '_billing_address_1' => $this->faker->streetAddress, - '_billing_address_2' => $this->faker->optional()->secondaryAddress, - '_billing_city' => $this->faker->city, - '_billing_state' => $this->faker->state, - '_billing_postcode' => $this->faker->postcode, - '_billing_country' => $this->faker->country, - '_billing_email' => $this->faker->email, - '_billing_phone' => $this->faker->phoneNumber, + '_billing_last_name' => $this->faker->lastName, + '_billing_company' => $this->faker->optional()->company, + '_billing_address_1' => $this->faker->streetAddress, + '_billing_address_2' => $this->faker->optional()->secondaryAddress, + '_billing_city' => $this->faker->city, + '_billing_state' => $this->faker->state, + '_billing_postcode' => $this->faker->postcode, + '_billing_country' => $this->faker->country, + '_billing_email' => $this->faker->email, + '_billing_phone' => $this->faker->phoneNumber, ]); }); } @@ -113,23 +113,23 @@ public function withMeta(): Factory /** * Applies withShipping state to model. * - * @return Factory + * @return Factory */ public function withShipping(): Factory { return $this->afterCreating(function (Order $order) { $order->createMeta([ - '_order_shipping' => $this->faker->randomFloat(2, 0, 200), - '_order_shipping_tax' => $this->faker->randomFloat(2, 0, 200), + '_order_shipping' => $this->faker->randomFloat(2, 0, 200), + '_order_shipping_tax' => $this->faker->randomFloat(2, 0, 200), '_shipping_first_name' => $this->faker->firstName, - '_shipping_last_name' => $this->faker->lastName, - '_shipping_company' => $this->faker->optional()->company, - '_shipping_address_1' => $this->faker->streetAddress, - '_shipping_address_2' => $this->faker->optional()->secondaryAddress, - '_shipping_city' => $this->faker->city, - '_shipping_state' => $this->faker->state, - '_shipping_postcode' => $this->faker->postcode, - '_shipping_country' => $this->faker->country, + '_shipping_last_name' => $this->faker->lastName, + '_shipping_company' => $this->faker->optional()->company, + '_shipping_address_1' => $this->faker->streetAddress, + '_shipping_address_2' => $this->faker->optional()->secondaryAddress, + '_shipping_city' => $this->faker->city, + '_shipping_state' => $this->faker->state, + '_shipping_postcode' => $this->faker->postcode, + '_shipping_country' => $this->faker->country, ]); }); } @@ -137,7 +137,7 @@ public function withShipping(): Factory /** * Applies paid state to model. * - * @return Factory + * @return Factory */ public function paid(): Factory { @@ -145,10 +145,10 @@ public function paid(): Factory $paymentMethod = $this->faker->word; $order->createMeta([ - '_date_paid' => $this->faker->dateTime->format('Y-m-d H:i:s'), - '_payment_method' => $paymentMethod, + '_date_paid' => $this->faker->dateTime->format('Y-m-d H:i:s'), + '_payment_method' => $paymentMethod, '_payment_method_title' => ucfirst($paymentMethod), - '_transaction_id' => $this->faker->asciify('*******'), + '_transaction_id' => $this->faker->asciify('*******'), ]); }); } diff --git a/tests/database/factories/ProductFactory.php b/tests/database/factories/ProductFactory.php index 8178360..c845859 100644 --- a/tests/database/factories/ProductFactory.php +++ b/tests/database/factories/ProductFactory.php @@ -29,28 +29,28 @@ public function definition() $name = $this->faker->sentence; return [ - 'post_author' => $this->faker->numberBetween(1, 100), - 'post_date' => $createdAt->format('Y-m-d H:i:s'), - 'post_date_gmt' => $createdAtGMT->format('Y-m-d H:i:s'), - 'post_content' => $this->faker->paragraphs(mt_rand(1, 5), true), - 'post_title' => $name, - 'post_excerpt' => $this->faker->paragraph, - 'post_status' => 'publish', - 'comment_status' => 'open', - 'ping_status' => 'closed', - 'post_password' => '', - 'post_name' => Str::title($name), - 'to_ping' => '', - 'pinged' => '', - 'post_modified' => $createdAt->format('Y-m-d H:i:s'), - 'post_modified_gmt' => $createdAtGMT->format('Y-m-d H:i:s'), + 'post_author' => $this->faker->numberBetween(1, 100), + 'post_date' => $createdAt->format('Y-m-d H:i:s'), + 'post_date_gmt' => $createdAtGMT->format('Y-m-d H:i:s'), + 'post_content' => $this->faker->paragraphs(mt_rand(1, 5), true), + 'post_title' => $name, + 'post_excerpt' => $this->faker->paragraph, + 'post_status' => 'publish', + 'comment_status' => 'open', + 'ping_status' => 'closed', + 'post_password' => '', + 'post_name' => Str::title($name), + 'to_ping' => '', + 'pinged' => '', + 'post_modified' => $createdAt->format('Y-m-d H:i:s'), + 'post_modified_gmt' => $createdAtGMT->format('Y-m-d H:i:s'), 'post_content_filtered' => '', - 'post_parent' => 0, - 'guid' => 'http://woocommerce.example/?post_type=product&p=1', - 'menu_order' => 0, - 'post_type' => 'product', - 'post_mime_type' => '', - 'comment_count' => 0, + 'post_parent' => 0, + 'guid' => 'http://woocommerce.example/?post_type=product&p=1', + 'menu_order' => 0, + 'post_type' => 'product', + 'post_mime_type' => '', + 'comment_count' => 0, ]; } }