From fc7d10f2a1764ce07cd1ff4786b511bec350b53d Mon Sep 17 00:00:00 2001 From: Vlad Shashkov Date: Wed, 17 Jun 2026 14:14:39 +0300 Subject: [PATCH 1/2] Fixed adjusting field results --- src/Response/Address.php | 11 +++++++++++ src/Response/SuggestAddress.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Response/Address.php b/src/Response/Address.php index 1510c25..09e2e87 100644 --- a/src/Response/Address.php +++ b/src/Response/Address.php @@ -1146,4 +1146,15 @@ public function getResult(): ?string { return $this->result; } + + /** + * @param non-empty-string $result + */ + public function withResult(string $result): self + { + $new = clone $this; + $new->result = $result; + + return $new; + } } diff --git a/src/Response/SuggestAddress.php b/src/Response/SuggestAddress.php index 0e956da..e30f886 100644 --- a/src/Response/SuggestAddress.php +++ b/src/Response/SuggestAddress.php @@ -34,7 +34,7 @@ final class SuggestAddress */ public function __construct(Address $data, string $value, string $unrestrictedValue) { - $this->data = $data; + $this->data = $data->withResult($value); $this->value = $value; $this->unrestrictedValue = $unrestrictedValue; } From 41b476e194cdacb82b56396f64a86069b69037b7 Mon Sep 17 00:00:00 2001 From: Vlad Shashkov Date: Fri, 3 Jul 2026 13:03:16 +0300 Subject: [PATCH 2/2] Added withNormalizedCity --- src/Response/Address.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Response/Address.php b/src/Response/Address.php index 09e2e87..d237540 100644 --- a/src/Response/Address.php +++ b/src/Response/Address.php @@ -1157,4 +1157,21 @@ public function withResult(string $result): self return $new; } + + /** + * @see https://support.dadata.ru/knowledge-bases/4/articles/1071-pochemu-dlya-moskvyi-i-pitera-pole-city-zapolnyaetsya-v-podskazkah-no-ne-v-standartizatsii + * @see https://support.dadata.ru/knowledge-bases/4/articles/51578-pole-city-dubliruet-region-ili-area-v-podskazkah-no-ne-v-standartizatsii + */ + public function withNormalizedCity(): self + { + $new = clone $this; + $new->city = $this->region; + $new->cityType = $this->regionType; + $new->cityTypeFull = $this->regionTypeFull; + $new->cityWithType = $this->regionWithType; + $new->cityKladrId = $this->regionKladrId; + $new->cityFiasId = $this->regionFiasId; + + return $new; + } }