Skip to content

Commit

Permalink
fix: type casting and nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
lsimeonov committed Nov 23, 2022
1 parent 30b6079 commit 6eb496b
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/Response/ProductOffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ class ProductOffer
*/
private string $partNumberKey;

private string $brandName;
private ?string $brandName;

private ?int $buyButtonRank;

private ?int $categoryId;

private int $id;

private string $brand;
private ?string $brand;

private ?int $vendorCategoryId;

Expand Down Expand Up @@ -132,7 +132,7 @@ class ProductOffer

private int $numberOfOffers;

private string $rrpGuidelines;
private ?string $rrpGuidelines;

/**
* @param array $params
Expand All @@ -142,31 +142,31 @@ public static function fromArray(array $params): self
{
$product = new self();
$product->setPartNumberKey($params['part_number_key']);
$product->setBrandName($params['brand_name']);
$product->setBrandName($params['brand_name'] ?? null);
$product->setBuyButtonRank($params['buy_button_rank'] ?? null);
$product->setCategoryId($params['category_id']);
$product->setId($params['id']);
$product->setBrand($params['brand']);
$product->setCategoryId($params['category_id'] ?? null);
$product->setId((int)$params['id']);
$product->setBrand($params['brand'] ?? null);
$product->setVendorCategoryId($params['vendor_category_id']);
$product->setName($params['name']);
$product->setSalePrice($params['sale_price']);
$product->setSalePrice((float)$params['sale_price']);
$product->setCurrency($params['currency']);
$product->setDescription($params['description']);
$product->setUrl($params['url']);
$product->setWarranty($params['warranty']);
$product->setGeneralStock($params['general_stock']);
$product->setWarranty((int)$params['warranty']);
$product->setGeneralStock((int)$params['general_stock']);
$product->setWeight($params['weight']);
$product->setStatus($params['status']);
$product->setRecommendedPrice($params['recommended_price']);
$product->setStatus((int)$params['status']);
$product->setRecommendedPrice((float)$params['recommended_price']);
$product->setImages($params['images']);
$product->setCharacteristics($params['characteristics']);
$product->setAttachments($params['attachments']);
$product->setVatId($params['vat_id']);
$product->setVatId((int)$params['vat_id']);
$product->setFamily($params['family']);
$product->setStartDate($params['start_date']);
$product->setEstimatedStock($params['estimated_stock']);
$product->setMinSalePrice($params['min_sale_price']);
$product->setMaxSalePrice($params['max_sale_price']);
$product->setEstimatedStock((int)$params['estimated_stock']);
$product->setMinSalePrice((float)$params['min_sale_price']);
$product->setMaxSalePrice((float)$params['max_sale_price']);
$product->setOfferDetails($params['offer_details']);
$product->setContentDetails($params['content_details']);
$product->setOfferProperties($params['offer_properties']);
Expand All @@ -178,11 +178,11 @@ public static function fromArray(array $params): self
$product->setCommission($params['commission']);
$product->setValidationStatus($params['validation_status']);
$product->setOfferValidationStatus($params['offer_validation_status']);
$product->setOwnership($params['ownership']);
$product->setBestOfferSalePrice($params['best_offer_sale_price']);
$product->setBestOfferRecommendedPrice($params['best_offer_recommended_price']);
$product->setNumberOfOffers($params['number_of_offers']);
$product->setRrpGuidelines($params['rrp_guidelines']);
$product->setOwnership((bool)$params['ownership']);
$product->setBestOfferSalePrice((float)$params['best_offer_sale_price']);
$product->setBestOfferRecommendedPrice((float)$params['best_offer_recommended_price']);
$product->setNumberOfOffers((int)$params['number_of_offers']);
$product->setRrpGuidelines($params['rrp_guidelines']??null);

return $product;
}
Expand All @@ -204,17 +204,17 @@ public function setPartNumberKey(string $partNumberKey): void
}

/**
* @return string
* @return string|null
*/
public function getBrandName(): string
public function getBrandName(): ?string
{
return $this->brandName;
return $this->brandName ?? null;
}

/**
* @param string $brandName
* @param string|null $brandName
*/
public function setBrandName(string $brandName): void
public function setBrandName(?string $brandName): void
{
$this->brandName = $brandName;
}
Expand Down Expand Up @@ -268,17 +268,17 @@ public function setId(int $id): void
}

/**
* @return string
* @return string|null
*/
public function getBrand(): string
public function getBrand(): ?string
{
return $this->brand;
}

/**
* @param string $brand
* @param string|null $brand
*/
public function setBrand(string $brand): void
public function setBrand(?string $brand): void
{
$this->brand = $brand;
}
Expand Down Expand Up @@ -845,17 +845,17 @@ public function setNumberOfOffers(int $numberOfOffers): void
}

/**
* @return string
* @return string|null
*/
public function getRrpGuidelines(): string
public function getRrpGuidelines(): ?string
{
return $this->rrpGuidelines;
return $this->rrpGuidelines??null;
}

/**
* @param string $rrpGuidelines
* @param string|null $rrpGuidelines
*/
public function setRrpGuidelines(string $rrpGuidelines): void
public function setRrpGuidelines(?string $rrpGuidelines): void
{
$this->rrpGuidelines = $rrpGuidelines;
}
Expand Down

0 comments on commit 6eb496b

Please sign in to comment.