Skip to content

Commit

Permalink
Merge pull request #6 from answear/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mglowala authored Aug 16, 2021
2 parents 14e788f + d767adc commit 5d3e8ce
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Response/Struct/Office.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Office
public string $info;
public string $currency;
public ?string $language;
public OpeningHours $openingHours;
public ?OpeningHours $openingHours;
public ?OpeningHours $halfDayOpeningHours = null;
/** @var ShipmentType[] */
public array $shipmentTypes;
Expand All @@ -48,8 +48,8 @@ public static function fromArray(array $officeData): self
Assert::string($officeData['info']);
Assert::stringNotEmpty($officeData['currency']);
Assert::nullOrString($officeData['language']);
Assert::integer($officeData['normalBusinessHoursFrom']);
Assert::integer($officeData['normalBusinessHoursTo']);
Assert::nullOrInteger($officeData['normalBusinessHoursFrom']);
Assert::nullOrInteger($officeData['normalBusinessHoursTo']);
Assert::nullOrInteger($officeData['halfDayBusinessHoursFrom']);
Assert::nullOrInteger($officeData['halfDayBusinessHoursTo']);
Assert::string($officeData['partnerCode']);
Expand All @@ -70,10 +70,12 @@ public static function fromArray(array $officeData): self
$office->info = $officeData['info'];
$office->currency = $officeData['currency'];
$office->language = $officeData['language'];
$office->openingHours = new OpeningHours(
$officeData['normalBusinessHoursFrom'],
$officeData['normalBusinessHoursTo']
);
if (null !== $officeData['normalBusinessHoursFrom'] && null !== $officeData['normalBusinessHoursTo']) {
$office->openingHours = new OpeningHours(
$officeData['normalBusinessHoursFrom'],
$officeData['normalBusinessHoursTo']
);
}
if (null !== $officeData['halfDayBusinessHoursFrom'] && null !== $officeData['halfDayBusinessHoursTo']) {
$office->halfDayOpeningHours = new OpeningHours(
$officeData['halfDayBusinessHoursFrom'],
Expand Down

0 comments on commit 5d3e8ce

Please sign in to comment.