@@ -37,70 +37,70 @@ class CompanyLookupResult {
3737 *
3838 * @var string
3939 */
40- protected string $ cvr ;
40+ protected string $ cvr = '' ;
41+
42+ /**
43+ * The P-Number number.
44+ *
45+ * @var string
46+ */
47+ protected string $ pNumber = '' ;
4148
4249 /**
4350 * Company name.
4451 *
4552 * @var string
4653 */
47- protected string $ name ;
54+ protected string $ name = '' ;
4855
4956 /**
5057 * Street of the person.
5158 *
5259 * @var string
5360 */
54- protected string $ street ;
61+ protected string $ street = '' ;
5562
5663 /**
5764 * Street house number of the person.
5865 *
5966 * @var string
6067 */
61- protected string $ houseNr ;
68+ protected string $ houseNr = '' ;
6269
6370 /**
6471 * Floor number of the person.
6572 *
6673 * @var string
6774 */
68- protected string $ floor ;
75+ protected string $ floor = '' ;
6976
7077 /**
7178 * Apartment number of the person.
7279 *
7380 * @var string
7481 */
75- protected string $ apartmentNr ;
82+ protected string $ apartmentNr = '' ;
7683
7784 /**
7885 * Postal code of the person.
7986 *
8087 * @var string
8188 */
82- protected string $ postalCode ;
89+ protected string $ postalCode = '' ;
8390
8491 /**
8592 * City of the person.
8693 *
8794 * @var string
8895 */
89- protected string $ city ;
96+ protected string $ city = '' ;
9097
9198 /**
9299 * Municipality code of the person.
93100 *
94101 * @var string
95102 */
96- protected string $ municipalityCode ;
97-
98- /**
99- * Address of the person.
100- *
101- * @var string
102- */
103- protected string $ address ;
103+ protected string $ municipalityCode = '' ;
104104
105105 /**
106106 * Check the state of successful.
@@ -162,6 +162,26 @@ public function setCvr(string $cpr): void {
162162 $ this ->cvr = $ cpr ;
163163 }
164164
165+ /**
166+ * Get P-Number number.
167+ *
168+ * @return string
169+ * P-Number.
170+ */
171+ public function getPnumber (): string {
172+ return $ this ->pNumber ;
173+ }
174+
175+ /**
176+ * Set P-Number number.
177+ *
178+ * @param string $pNumber
179+ * P-Number.
180+ */
181+ public function setPnumber (string $ pNumber ): void {
182+ $ this ->pNumber = $ pNumber ;
183+ }
184+
165185 /**
166186 * Get name.
167187 *
@@ -329,17 +349,21 @@ public function setMunicipalityCode(string $municipalityCode): void {
329349 * The address.
330350 */
331351 public function getAddress (): string {
332- return $ this ->address ;
333- }
352+ $ address = $ this ->getStreet ();
353+ if ($ this ->getHouseNr ()) {
354+ $ address .= ' ' . $ this ->getHouseNr ();
355+ }
356+ if ($ this ->getFloor ()) {
357+ $ address .= ' ' . $ this ->getFloor ();
358+ }
359+ if ($ this ->getApartmentNr ()) {
360+ $ address .= ' ' . $ this ->getApartmentNr ();
361+ }
362+ if ($ this ->getPostalCode () && $ this ->getCity ()) {
363+ $ address .= ', ' . $ this ->getPostalCode () . ' ' . $ this ->getCity ();
364+ }
334365
335- /**
336- * Set address.
337- *
338- * @param string $address
339- * The address to set.
340- */
341- public function setAddress (string $ address ): void {
342- $ this ->address = $ address ;
366+ return $ address ;
343367 }
344368
345369 /**
@@ -352,6 +376,14 @@ public function setAddress(string $address): void {
352376 * The field value or the empty string if the field does not exist.
353377 */
354378 public function getFieldValue (string $ field ): mixed {
379+ $ calculatedFields = [
380+ $ this ::ADDRESS => fn () => $ this ->getAddress (),
381+ ];
382+
383+ if (isset ($ calculatedFields [$ field ])) {
384+ return $ calculatedFields [$ field ]();
385+ }
386+
355387 if (property_exists ($ this , $ field ) && isset ($ this ->{$ field })) {
356388 return $ this ->{$ field };
357389 }
0 commit comments