From f7ee5ba89448959ac4da5a8c632fcd7f547f8bbd Mon Sep 17 00:00:00 2001 From: xmalda <24293733+xmalda@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:02:40 +0100 Subject: [PATCH] [create-pull-request] automated change --- src/Component/Entity/EntityCollection.php | 52 +++++++++++++++++++ .../ValueObject/ConsumptionTaxId.php | 5 ++ src/Component/ValueObject/TypeAmount.php | 5 ++ .../ValueObject/TypeAmountNullable.php | 5 ++ src/Component/ValueObject/TypeColor.php | 5 ++ src/Component/ValueObject/TypeConstSymbol.php | 5 ++ .../ValueObject/TypeConstSymbolNullable.php | 5 ++ .../ValueObject/TypeCurrencyCode.php | 5 ++ .../ValueObject/TypeCurrencyCodeNullable.php | 5 ++ .../ValueObject/TypeCustomerFieldValue.php | 5 ++ src/Component/ValueObject/TypeDate.php | 5 ++ .../ValueObject/TypeDateNullable.php | 5 ++ src/Component/ValueObject/TypeDateTime.php | 5 ++ .../ValueObject/TypeDateTimeNullable.php | 5 ++ .../ValueObject/TypeDateTimeRequest.php | 5 ++ src/Component/ValueObject/TypeDimension.php | 5 ++ .../ValueObject/TypeExchangeRate.php | 5 ++ src/Component/ValueObject/TypeFilename.php | 5 ++ .../ValueObject/TypeFilenameNullable.php | 5 ++ src/Component/ValueObject/TypeGuid.php | 5 ++ .../ValueObject/TypeGuidNullable.php | 5 ++ .../ValueObject/TypeGuidUnlimited.php | 5 ++ .../ValueObject/TypeNonEmptyString.php | 5 ++ .../ValueObject/TypePositiveAmount.php | 5 ++ .../TypePositiveAmountNullable.php | 5 ++ src/Component/ValueObject/TypePrice.php | 5 ++ .../ValueObject/TypePriceNullable.php | 5 ++ src/Component/ValueObject/TypePriceRatio.php | 5 ++ .../ValueObject/TypeProductPriceRatio.php | 5 ++ src/Component/ValueObject/TypeUnitRatio.php | 5 ++ .../ValueObject/TypeVariantCodeRequest.php | 5 ++ src/Component/ValueObject/TypeVatRate.php | 5 ++ src/Component/ValueObject/TypeWeight.php | 5 ++ .../ValueObject/TypeWeightRequest.php | 5 ++ .../ValueObject/TypeWeightUnlimited.php | 5 ++ .../ValueObject/ValueObjectInterface.php | 4 +- tests/Unit/Helper/DummyValueObject.php | 5 ++ 37 files changed, 230 insertions(+), 1 deletion(-) diff --git a/src/Component/Entity/EntityCollection.php b/src/Component/Entity/EntityCollection.php index 7f8d7826..7d5c334d 100755 --- a/src/Component/Entity/EntityCollection.php +++ b/src/Component/Entity/EntityCollection.php @@ -7,6 +7,8 @@ use Countable; use IteratorAggregate; use JsonSerializable; +use ReflectionClass; +use ReflectionException; use Shoptet\Api\Sdk\Php\Exception\InvalidArgumentException; use Traversable; @@ -222,4 +224,54 @@ public function jsonSerialize(): array { return $this->toArray(); } + + /** + * @param string $multiType + * @param array $data + * @return class-string + */ + protected function determineMultiTypeByData(string $multiType, array $data): string + { + /** + * @var array> $types + */ + $types = explode('|', $multiType); + /** + * @var array> $result + */ + $result = $types; + + foreach ($types as $i => $type) { + try { + $reflection = new ReflectionClass($type); + } catch (ReflectionException $e) { // @phpstan-ignore catch.neverThrown + //Better Safe than Sorry + throw new InvalidArgumentException(sprintf('Cannot determine data type of "%s" due to unprocessable type "%s".', $multiType, $type), $e->getCode(), $e); + } + + foreach ($reflection->getProperties() as $property) { + if ($property->getName() === 'undefinedParams') { + continue; + } + + if (!$property->getType()?->allowsNull() && !array_key_exists($property->getName(), $data)) { + unset($result[$i]); + continue 2; + } + } + + foreach ($data as $property => $value) { + if (!$reflection->hasProperty($property)) { + unset($result[$i]); + continue 2; + } + } + } + + if (empty($result)) { + throw new InvalidArgumentException(sprintf('Cannot determine data type of "%s" based on "%s".', $multiType, var_export($data, true))); + } + + return reset($result); + } } diff --git a/src/Component/ValueObject/ConsumptionTaxId.php b/src/Component/ValueObject/ConsumptionTaxId.php index b8c22005..d8a367c8 100755 --- a/src/Component/ValueObject/ConsumptionTaxId.php +++ b/src/Component/ValueObject/ConsumptionTaxId.php @@ -21,4 +21,9 @@ public function __toString(): string { return (string) $this->consumptionTaxId; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeAmount.php b/src/Component/ValueObject/TypeAmount.php index 7dcf3f1d..ff437fc3 100755 --- a/src/Component/ValueObject/TypeAmount.php +++ b/src/Component/ValueObject/TypeAmount.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeAmount; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeAmountNullable.php b/src/Component/ValueObject/TypeAmountNullable.php index 26214171..e7af5cfd 100755 --- a/src/Component/ValueObject/TypeAmountNullable.php +++ b/src/Component/ValueObject/TypeAmountNullable.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeAmountNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeColor.php b/src/Component/ValueObject/TypeColor.php index 80c795f2..6ed81268 100755 --- a/src/Component/ValueObject/TypeColor.php +++ b/src/Component/ValueObject/TypeColor.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeColor; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeConstSymbol.php b/src/Component/ValueObject/TypeConstSymbol.php index 0d666697..b6adb9b4 100755 --- a/src/Component/ValueObject/TypeConstSymbol.php +++ b/src/Component/ValueObject/TypeConstSymbol.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeConstSymbol; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeConstSymbolNullable.php b/src/Component/ValueObject/TypeConstSymbolNullable.php index 4b6db8b4..7b8d89d1 100755 --- a/src/Component/ValueObject/TypeConstSymbolNullable.php +++ b/src/Component/ValueObject/TypeConstSymbolNullable.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeConstSymbolNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeCurrencyCode.php b/src/Component/ValueObject/TypeCurrencyCode.php index 3e224c8b..1bcde71c 100755 --- a/src/Component/ValueObject/TypeCurrencyCode.php +++ b/src/Component/ValueObject/TypeCurrencyCode.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeCurrencyCode; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeCurrencyCodeNullable.php b/src/Component/ValueObject/TypeCurrencyCodeNullable.php index 7cccd636..d3cc859b 100755 --- a/src/Component/ValueObject/TypeCurrencyCodeNullable.php +++ b/src/Component/ValueObject/TypeCurrencyCodeNullable.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeCurrencyCodeNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeCustomerFieldValue.php b/src/Component/ValueObject/TypeCustomerFieldValue.php index 311ecf19..32619800 100755 --- a/src/Component/ValueObject/TypeCustomerFieldValue.php +++ b/src/Component/ValueObject/TypeCustomerFieldValue.php @@ -24,4 +24,9 @@ public function __toString(): string { return (string) $this->typeCustomerFieldValue; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeDate.php b/src/Component/ValueObject/TypeDate.php index a04d31f7..3464f7a7 100755 --- a/src/Component/ValueObject/TypeDate.php +++ b/src/Component/ValueObject/TypeDate.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeDate; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeDateNullable.php b/src/Component/ValueObject/TypeDateNullable.php index ec4cc72a..da3fe42e 100755 --- a/src/Component/ValueObject/TypeDateNullable.php +++ b/src/Component/ValueObject/TypeDateNullable.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeDateNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeDateTime.php b/src/Component/ValueObject/TypeDateTime.php index 39eef7be..ce2b1877 100755 --- a/src/Component/ValueObject/TypeDateTime.php +++ b/src/Component/ValueObject/TypeDateTime.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeDateTime; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeDateTimeNullable.php b/src/Component/ValueObject/TypeDateTimeNullable.php index bb9e531d..7be5cc16 100755 --- a/src/Component/ValueObject/TypeDateTimeNullable.php +++ b/src/Component/ValueObject/TypeDateTimeNullable.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeDateTimeNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeDateTimeRequest.php b/src/Component/ValueObject/TypeDateTimeRequest.php index bfdfba3e..abfe4d58 100755 --- a/src/Component/ValueObject/TypeDateTimeRequest.php +++ b/src/Component/ValueObject/TypeDateTimeRequest.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeDateTimeRequest; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeDimension.php b/src/Component/ValueObject/TypeDimension.php index 8ba77dab..fdeb35bf 100755 --- a/src/Component/ValueObject/TypeDimension.php +++ b/src/Component/ValueObject/TypeDimension.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeDimension; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeExchangeRate.php b/src/Component/ValueObject/TypeExchangeRate.php index c7464b18..fec824ac 100755 --- a/src/Component/ValueObject/TypeExchangeRate.php +++ b/src/Component/ValueObject/TypeExchangeRate.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeExchangeRate; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeFilename.php b/src/Component/ValueObject/TypeFilename.php index 5e5aa8a9..5546aa20 100755 --- a/src/Component/ValueObject/TypeFilename.php +++ b/src/Component/ValueObject/TypeFilename.php @@ -29,4 +29,9 @@ public function __toString(): string { return (string) $this->typeFilename; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeFilenameNullable.php b/src/Component/ValueObject/TypeFilenameNullable.php index a1082fe8..d4f54a40 100755 --- a/src/Component/ValueObject/TypeFilenameNullable.php +++ b/src/Component/ValueObject/TypeFilenameNullable.php @@ -32,4 +32,9 @@ public function __toString(): string { return (string) $this->typeFilenameNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeGuid.php b/src/Component/ValueObject/TypeGuid.php index 141c3ba3..2e86655b 100755 --- a/src/Component/ValueObject/TypeGuid.php +++ b/src/Component/ValueObject/TypeGuid.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeGuid; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeGuidNullable.php b/src/Component/ValueObject/TypeGuidNullable.php index 771c3793..3f449542 100755 --- a/src/Component/ValueObject/TypeGuidNullable.php +++ b/src/Component/ValueObject/TypeGuidNullable.php @@ -29,4 +29,9 @@ public function __toString(): string { return (string) $this->typeGuidNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeGuidUnlimited.php b/src/Component/ValueObject/TypeGuidUnlimited.php index c9fd80b7..5719841a 100755 --- a/src/Component/ValueObject/TypeGuidUnlimited.php +++ b/src/Component/ValueObject/TypeGuidUnlimited.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeGuidUnlimited; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeNonEmptyString.php b/src/Component/ValueObject/TypeNonEmptyString.php index ee85a513..b5995b79 100755 --- a/src/Component/ValueObject/TypeNonEmptyString.php +++ b/src/Component/ValueObject/TypeNonEmptyString.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeNonEmptyString; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypePositiveAmount.php b/src/Component/ValueObject/TypePositiveAmount.php index f2e68c6c..bfebdfde 100755 --- a/src/Component/ValueObject/TypePositiveAmount.php +++ b/src/Component/ValueObject/TypePositiveAmount.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typePositiveAmount; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypePositiveAmountNullable.php b/src/Component/ValueObject/TypePositiveAmountNullable.php index 99617a75..62e97db8 100755 --- a/src/Component/ValueObject/TypePositiveAmountNullable.php +++ b/src/Component/ValueObject/TypePositiveAmountNullable.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typePositiveAmountNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypePrice.php b/src/Component/ValueObject/TypePrice.php index dc113293..6997979d 100755 --- a/src/Component/ValueObject/TypePrice.php +++ b/src/Component/ValueObject/TypePrice.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typePrice; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypePriceNullable.php b/src/Component/ValueObject/TypePriceNullable.php index 1b3950e4..dfeac7b1 100755 --- a/src/Component/ValueObject/TypePriceNullable.php +++ b/src/Component/ValueObject/TypePriceNullable.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typePriceNullable; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypePriceRatio.php b/src/Component/ValueObject/TypePriceRatio.php index 3a02eed1..d926e5f1 100755 --- a/src/Component/ValueObject/TypePriceRatio.php +++ b/src/Component/ValueObject/TypePriceRatio.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typePriceRatio; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeProductPriceRatio.php b/src/Component/ValueObject/TypeProductPriceRatio.php index 4756ee72..cce44694 100755 --- a/src/Component/ValueObject/TypeProductPriceRatio.php +++ b/src/Component/ValueObject/TypeProductPriceRatio.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeProductPriceRatio; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeUnitRatio.php b/src/Component/ValueObject/TypeUnitRatio.php index baa01a47..beaa34e6 100755 --- a/src/Component/ValueObject/TypeUnitRatio.php +++ b/src/Component/ValueObject/TypeUnitRatio.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeUnitRatio; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeVariantCodeRequest.php b/src/Component/ValueObject/TypeVariantCodeRequest.php index 9f004c29..94eec1e3 100755 --- a/src/Component/ValueObject/TypeVariantCodeRequest.php +++ b/src/Component/ValueObject/TypeVariantCodeRequest.php @@ -29,4 +29,9 @@ public function __toString(): string { return (string) $this->typeVariantCodeRequest; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeVatRate.php b/src/Component/ValueObject/TypeVatRate.php index cba922a3..e00fc598 100755 --- a/src/Component/ValueObject/TypeVatRate.php +++ b/src/Component/ValueObject/TypeVatRate.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeVatRate; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeWeight.php b/src/Component/ValueObject/TypeWeight.php index 1c210007..46ecd231 100755 --- a/src/Component/ValueObject/TypeWeight.php +++ b/src/Component/ValueObject/TypeWeight.php @@ -23,4 +23,9 @@ public function __toString(): string { return (string) $this->typeWeight; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeWeightRequest.php b/src/Component/ValueObject/TypeWeightRequest.php index 26fd8c15..9a51d52a 100755 --- a/src/Component/ValueObject/TypeWeightRequest.php +++ b/src/Component/ValueObject/TypeWeightRequest.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeWeightRequest; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/TypeWeightUnlimited.php b/src/Component/ValueObject/TypeWeightUnlimited.php index 62f19810..001cb4a5 100755 --- a/src/Component/ValueObject/TypeWeightUnlimited.php +++ b/src/Component/ValueObject/TypeWeightUnlimited.php @@ -26,4 +26,9 @@ public function __toString(): string { return (string) $this->typeWeightUnlimited; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } } diff --git a/src/Component/ValueObject/ValueObjectInterface.php b/src/Component/ValueObject/ValueObjectInterface.php index 8d8c3677..637ad18b 100755 --- a/src/Component/ValueObject/ValueObjectInterface.php +++ b/src/Component/ValueObject/ValueObjectInterface.php @@ -2,7 +2,9 @@ namespace Shoptet\Api\Sdk\Php\Component\ValueObject; -interface ValueObjectInterface +use JsonSerializable; + +interface ValueObjectInterface extends JsonSerializable { public function __toString(): string; } diff --git a/tests/Unit/Helper/DummyValueObject.php b/tests/Unit/Helper/DummyValueObject.php index 95148140..ac4311f1 100755 --- a/tests/Unit/Helper/DummyValueObject.php +++ b/tests/Unit/Helper/DummyValueObject.php @@ -10,4 +10,9 @@ public function __toString(): string { return 'dummy-value-object'; } + + public function jsonSerialize(): string + { + return $this->__toString(); + } }