From 7a916c9df305fcd347b3d98d59e2f21112c2cbd7 Mon Sep 17 00:00:00 2001 From: Konrad Date: Wed, 9 Feb 2022 14:24:40 +0100 Subject: [PATCH] Add parcel property to ParcelShop DTO --- src/Response/DTO/ParcelShop.php | 1 + src/Serializer/CamelCaseToPascalCaseNameConverter.php | 4 ++-- src/Serializer/Normalizer/EnumNormalizer.php | 5 +++++ tests/Integration/Service/ParcelShopsTest.php | 1 + tests/Integration/Service/data/parcelShops.json | 5 +++++ .../Service/data/parcelShops_expected_parcels.json | 6 ++++++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Response/DTO/ParcelShop.php b/src/Response/DTO/ParcelShop.php index 768ce7e..959cd00 100644 --- a/src/Response/DTO/ParcelShop.php +++ b/src/Response/DTO/ParcelShop.php @@ -10,6 +10,7 @@ class ParcelShop public int $centerId; public string $shortName; public string $remark = ''; + public ?string $partner = null; public ?bool $delivery; public ?bool $dropoff; public Address $address; diff --git a/src/Serializer/CamelCaseToPascalCaseNameConverter.php b/src/Serializer/CamelCaseToPascalCaseNameConverter.php index 51e9c7c..0b52de2 100644 --- a/src/Serializer/CamelCaseToPascalCaseNameConverter.php +++ b/src/Serializer/CamelCaseToPascalCaseNameConverter.php @@ -8,7 +8,7 @@ class CamelCaseToPascalCaseNameConverter implements NameConverterInterface { - public function normalize($propertyName) + public function normalize($propertyName): string { return ucfirst($propertyName); } @@ -16,7 +16,7 @@ public function normalize($propertyName) /** * {@inheritdoc} */ - public function denormalize($propertyName) + public function denormalize($propertyName): string { $doubleU = preg_replace_callback( '/[A-Z]{2,}/', diff --git a/src/Serializer/Normalizer/EnumNormalizer.php b/src/Serializer/Normalizer/EnumNormalizer.php index 654454f..0d5c66f 100644 --- a/src/Serializer/Normalizer/EnumNormalizer.php +++ b/src/Serializer/Normalizer/EnumNormalizer.php @@ -11,6 +11,9 @@ class EnumNormalizer implements NormalizerInterface, DenormalizerInterface { + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ public function normalize($object, $format = null, array $context = []) { if (!$object instanceof Enum) { @@ -38,6 +41,8 @@ public function supportsDenormalization($data, $type, $format = null): bool /** * @see Enum for $type + * + * @return array|string|int|float|bool|\ArrayObject|null */ public function denormalize($data, $type, $format = null, array $context = []) { diff --git a/tests/Integration/Service/ParcelShopsTest.php b/tests/Integration/Service/ParcelShopsTest.php index 2b66ce5..c7f0587 100644 --- a/tests/Integration/Service/ParcelShopsTest.php +++ b/tests/Integration/Service/ParcelShopsTest.php @@ -122,6 +122,7 @@ private function assertOfficeSame(array $parcelShops): void ], 'remark' => $parcelShop->remark, 'shortName' => $parcelShop->shortName, + 'partner' => $parcelShop->partner, 'address' => [ 'name' => $address->name, 'addressId' => $address->addressId, diff --git a/tests/Integration/Service/data/parcelShops.json b/tests/Integration/Service/data/parcelShops.json index 19fac1a..e1b1d1a 100644 --- a/tests/Integration/Service/data/parcelShops.json +++ b/tests/Integration/Service/data/parcelShops.json @@ -8,6 +8,7 @@ "Dropoff": false, "GeoLat": 45.97585870, "GeoLong": 17.17087710, + "Partner": "BOSO", "Address": { "Name": "BS KLOŠTAR PODRAVSKI", "ZipCode": "48362", @@ -106,6 +107,7 @@ "Dropoff": true, "GeoLat": 45.75366760, "GeoLong": 15.89560960, + "Partner": "iNOVINE", "Address": { "Name": "POSLOVNICA", "ZipCode": "10251", @@ -135,6 +137,7 @@ "Dropoff": true, "GeoLat": 45.89170900, "GeoLong": 16.83863500, + "Partner": "iNOVINE", "Address": { "Name": "POSLOVNICA", "ZipCode": "43000", @@ -162,6 +165,7 @@ "Dropoff": false, "GeoLat": 45.23975990, "GeoLong": 13.93730920, + "Partner": "BOSO", "Address": { "Name": "IN974", "ZipCode": "52000", @@ -203,6 +207,7 @@ "Dropoff": false, "GeoLat": 44.53436667, "GeoLong": 14.91296667, + "Partner": "iNOVINE", "Address": { "Name": "BS KOLAN PAG", "ZipCode": "53291", diff --git a/tests/Integration/Service/data/parcelShops_expected_parcels.json b/tests/Integration/Service/data/parcelShops_expected_parcels.json index d3fa140..6dd16e8 100644 --- a/tests/Integration/Service/data/parcelShops_expected_parcels.json +++ b/tests/Integration/Service/data/parcelShops_expected_parcels.json @@ -10,6 +10,7 @@ }, "remark": "", "shortName": "CR3403", + "partner": "BOSO", "address": { "name": "BS KLO\u0160TAR PODRAVSKI", "addressId": null, @@ -58,6 +59,7 @@ }, "remark": "", "shortName": "IN702", + "partner": null, "address": { "name": "IN702", "addressId": null, @@ -124,6 +126,7 @@ }, "remark": "ISPORUKE I PREUZIMANJA U POSLOVNICI, neaktivno", "shortName": "OEXZG", + "partner": "iNOVINE", "address": { "name": "POSLOVNICA", "addressId": null, @@ -160,6 +163,7 @@ }, "remark": "", "shortName": "OEXBJ", + "partner": "iNOVINE", "address": { "name": "POSLOVNICA", "addressId": null, @@ -196,6 +200,7 @@ }, "remark": "", "shortName": "IN974", + "partner": "BOSO", "address": { "name": "IN974", "addressId": null, @@ -244,6 +249,7 @@ }, "remark": "", "shortName": "TF035", + "partner": "iNOVINE", "address": { "name": "BS KOLAN PAG", "addressId": null,