Skip to content

Commit cb947c6

Browse files
committed
refactor: Improve setClassifiedTaxCategory and setTaxCategory to accept both single TaxCategory objects and arrays, ensuring flexibility and better usability.
1 parent e9bd8f1 commit cb947c6

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/AllowanceCharge.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,16 @@ public function getTaxCategory(): ?TaxCategory
201201
/**
202202
* Set the tax category.
203203
*
204-
* @param TaxCategory|null $taxCategory
204+
* @param TaxCategory|array|null $taxCategory
205205
* @return self
206206
*/
207-
public function setTaxCategory(?array $taxCategory): self
207+
public function setTaxCategory(TaxCategory|array|null $taxCategory): self
208208
{
209-
$this->taxCategory = $taxCategory;
209+
if ($taxCategory instanceof TaxCategory) {
210+
$this->taxCategory = [$taxCategory];
211+
} else {
212+
$this->taxCategory = $taxCategory;
213+
}
210214
return $this;
211215
}
212216

src/Item.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,16 @@ public function getSellersItemIdentification(): ?string
159159
/**
160160
* Set the classified tax category.
161161
*
162-
* @param array|null $classifiedTaxCategory
162+
* @param ClassifiedTaxCategory|array|null $classifiedTaxCategory
163163
* @return self
164164
*/
165-
public function setClassifiedTaxCategory(?array $classifiedTaxCategory): self
165+
public function setClassifiedTaxCategory(ClassifiedTaxCategory|array|null $classifiedTaxCategory): self
166166
{
167-
$this->classifiedTaxCategory = $classifiedTaxCategory;
167+
if ($classifiedTaxCategory instanceof ClassifiedTaxCategory) {
168+
$this->classifiedTaxCategory = [$classifiedTaxCategory];
169+
} else {
170+
$this->classifiedTaxCategory = $classifiedTaxCategory;
171+
}
168172
return $this;
169173
}
170174

0 commit comments

Comments
 (0)