From 04292a186d620521c4c98ea7b131057268a44461 Mon Sep 17 00:00:00 2001 From: Tjardo Date: Tue, 23 Jun 2026 15:22:33 +0200 Subject: [PATCH] Neighborhood support --- README.md | 5 ++++- src/DTO/Address.php | 1 + src/Enums/AddressAttributesEnum.php | 1 + src/Factories/AddressCollectionFactory.php | 1 + src/Factories/AddressFactory.php | 2 ++ tests/TestCase.php | 5 +++++ 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8716b3a..e701a6a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ You can search addresses using either the `find` method for a single address or The following optional attributes can be requested to be included in the response: - `coordinates`: Includes latitude and longitude of the address. -- `district`: Includes the official and name of the district that the address belongs to. +- `district`: Includes the official and common name of the district that the address belongs to. +- `neighborhood`: Includes the official name of the neighborhood that the address belongs to. - `function`: Includes the function of the address (e.g. residential, commercial, healthcare, etc.). - `location_status`: Includes the location status of the address (e.g. active, in development, etc.). - `property_status`: Includes the property status of the address (e.g. in use, under construction, etc.). @@ -88,6 +89,7 @@ $address = $client->find( addition: null, attributes: [ AddressAttributesEnum::COORDINATES, + // more attributes can be added here ], ); ``` @@ -111,6 +113,7 @@ Address { official: "Schiphol", name: "Schiphol" }, + neighborhood: "Schiphol", function: "kantoorfunctie", location_status: "verblijfsobject in gebruik", property_status: "pand in gebruik", diff --git a/src/DTO/Address.php b/src/DTO/Address.php index bb5a231..e10af1e 100644 --- a/src/DTO/Address.php +++ b/src/DTO/Address.php @@ -15,6 +15,7 @@ public function __construct( public readonly string $country, public readonly ?Coordinates $coordinates, public readonly ?District $district, + public readonly ?string $neighborhood, public readonly ?string $function, public readonly ?string $location_status, public readonly ?string $property_status, diff --git a/src/Enums/AddressAttributesEnum.php b/src/Enums/AddressAttributesEnum.php index db87143..e3dc073 100644 --- a/src/Enums/AddressAttributesEnum.php +++ b/src/Enums/AddressAttributesEnum.php @@ -6,6 +6,7 @@ enum AddressAttributesEnum: string { case COORDINATES = 'coordinates'; case DISTRICT = 'district'; + case NEIGHBORHOOD = 'neighborhood'; case FUNCTION = 'function'; case LOCATION_STATUS = 'location_status'; case PROPERTY_STATUS = 'property_status'; diff --git a/src/Factories/AddressCollectionFactory.php b/src/Factories/AddressCollectionFactory.php index ad6011d..c8fbcdd 100644 --- a/src/Factories/AddressCollectionFactory.php +++ b/src/Factories/AddressCollectionFactory.php @@ -26,6 +26,7 @@ class AddressCollectionFactory * official: string, * name: string, * }, + * neighborhood?: string, * function?: string, * location_status?: string, * property_status?: string, diff --git a/src/Factories/AddressFactory.php b/src/Factories/AddressFactory.php index c5f4df5..68f0b2f 100644 --- a/src/Factories/AddressFactory.php +++ b/src/Factories/AddressFactory.php @@ -27,6 +27,7 @@ class AddressFactory * official: string, * name: string, * }, + * neighborhood?: string, * function?: string, * location_status?: string, * property_status?: string, @@ -54,6 +55,7 @@ public static function make(array $attributes): Address official: $attributes['details']['district']['official'], name: $attributes['details']['district']['name'], ) : null, + neighborhood: $attributes['details']['neighborhood'] ?? null, function: $attributes['details']['function'] ?? null, location_status: $attributes['details']['location_status'] ?? null, property_status: $attributes['details']['property_status'] ?? null, diff --git a/tests/TestCase.php b/tests/TestCase.php index ba3ae65..54ba6c3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -97,6 +97,7 @@ private function singleAddressResponse(): AddressCollection latitude: 52.30528553688755, longitude: 4.750645160863609, ), + neighborhood: null, district: null, function: null, location_status: null, @@ -124,6 +125,7 @@ private function multipleAddressesResponse(): AddressCollection longitude: 4.889216673725493, ), district: null, + neighborhood: null, function: null, location_status: null, property_status: null, @@ -144,6 +146,7 @@ function: null, longitude: 4.889216673725493, ), district: null, + neighborhood: null, function: null, location_status: null, property_status: null, @@ -164,6 +167,7 @@ function: null, longitude: 4.889216673725493, ), district: null, + neighborhood: null, function: null, location_status: null, property_status: null, @@ -184,6 +188,7 @@ function: null, longitude: 4.889216673725493, ), district: null, + neighborhood: null, function: null, location_status: null, property_status: null,