From 601b2e10ea46f09523e9da38840b0a4baadeae1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matthias=20Bl=C3=BCmel?=
Date: Sat, 2 Sep 2023 23:07:21 +0200
Subject: [PATCH 1/8] codestyle
Change-Id: I027d3351fc77193d610b24d200c75cc733639717
---
index.php | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/index.php b/index.php
index b4ad82b..4910f97 100644
--- a/index.php
+++ b/index.php
@@ -5,19 +5,21 @@
?>
-
- commit hygiene example
-
+
+ commit hygiene example
+
@@ -25,13 +27,15 @@
-
+?>
+
- commit hygiene example
+ commit hygiene example
- =$user->getFirstName() . ' ' . $user->getLastName()?>
- =$user->getStreet()?>
=$user->getZip()?> =$user->getCity()?>
+
= $user->getFirstName() . ' ' . $user->getLastName() ?>
+
+ = $user->getStreet() ?>
+ = $user->getZip() ?> = $user->getCity() ?>
-
Date: Sun, 3 Sep 2023 00:00:24 +0200
Subject: [PATCH 7/8] abstract Address from User
Change-Id: If105072e08c6a8e7686b4aa6227e2b0e630ed514
---
dto.php | 25 +++++++++++++++++++------
index.php | 10 +++++-----
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/dto.php b/dto.php
index f2ad13f..920c8dc 100644
--- a/dto.php
+++ b/dto.php
@@ -3,16 +3,13 @@
class User {
private string $firstName;
private string $lastName;
- private string $street;
- private string $zip;
- private string $city;
+
+ private Address $address;
public function __construct(array $data) {
$this->firstName = $data['firstName'];
$this->lastName = $data['lastName'];
- $this->street = $data['street'];
- $this->zip = $data['zip'];
- $this->city = $data['city'];
+ $this->address = new Address($data['address']);
}
public function getFirstName(): string {
@@ -23,6 +20,22 @@ public function getLastName(): string {
return $this->lastName;
}
+ public function getAddress(): Address {
+ return $this->address;
+ }
+}
+
+class Address {
+ private string $street;
+ private string $zip;
+ private string $city;
+
+ public function __construct(array $data) {
+ $this->street = $data['street'];
+ $this->zip = $data['zip'];
+ $this->city = $data['city'];
+ }
+
public function getStreet(): string {
return $this->street;
}
diff --git a/index.php b/index.php
index adb7e30..4aba675 100644
--- a/index.php
+++ b/index.php
@@ -12,9 +12,9 @@
@@ -29,8 +29,8 @@
= htmlspecialchars($user->getFirstName() . ' ' . $user->getLastName(), ENT_HTML5) ?>
- = htmlspecialchars($user->getStreet(), ENT_HTML5) ?>
- = htmlspecialchars($user->getZip(), ENT_HTML5) ?> = htmlspecialchars($user->getCity(), ENT_HTML5) ?>
+ = htmlspecialchars($user->getAddress()->getStreet(), ENT_HTML5) ?>
+ = htmlspecialchars($user->getAddress()->getZip(), ENT_HTML5) ?> = htmlspecialchars($user->getAddress()->getCity(), ENT_HTML5) ?>
From dae2edc6f575cddbaeedce568c97152f8efa06dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matthias=20Bl=C3=BCmel?=
Date: Sat, 2 Sep 2023 23:50:46 +0200
Subject: [PATCH 8/8] allow to set a separate delivery address
Change-Id: Iaf90a2b6e7cf0e4af2f486170d7079f1c4300152
---
dto.php | 16 ++++++++++++----
index.php | 21 ++++++++++++++++-----
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/dto.php b/dto.php
index 920c8dc..a94ff80 100644
--- a/dto.php
+++ b/dto.php
@@ -4,12 +4,16 @@ class User {
private string $firstName;
private string $lastName;
- private Address $address;
+ private Address $invoiceAddress;
+ private Address|null $deliveryAddress = null;
public function __construct(array $data) {
$this->firstName = $data['firstName'];
$this->lastName = $data['lastName'];
- $this->address = new Address($data['address']);
+ $this->invoiceAddress = new Address($data['invoiceAddress']);
+ if (empty($data['deliveryAddress']['street'])) {
+ $this->deliveryAddress = new Address($data['deliveryAddress']);
+ }
}
public function getFirstName(): string {
@@ -20,8 +24,12 @@ public function getLastName(): string {
return $this->lastName;
}
- public function getAddress(): Address {
- return $this->address;
+ public function getInvoiceAddress(): Address {
+ return $this->invoiceAddress;
+ }
+
+ public function getDeliveryAddress(): Address {
+ return $this->deliveryAddress ?: $this->invoiceAddress;
}
}
diff --git a/index.php b/index.php
index 4aba675..df51736 100644
--- a/index.php
+++ b/index.php
@@ -12,9 +12,14 @@
@@ -28,9 +33,15 @@
commit hygiene example
= htmlspecialchars($user->getFirstName() . ' ' . $user->getLastName(), ENT_HTML5) ?>
+ invoice address
- = htmlspecialchars($user->getAddress()->getStreet(), ENT_HTML5) ?>
- = htmlspecialchars($user->getAddress()->getZip(), ENT_HTML5) ?> = htmlspecialchars($user->getAddress()->getCity(), ENT_HTML5) ?>
+ = htmlspecialchars($user->getInvoiceAddress()->getStreet(), ENT_HTML5) ?>
+ = htmlspecialchars($user->getInvoiceAddress()->getZip(), ENT_HTML5) ?> = htmlspecialchars($user->getInvoiceAddress()->getCity(), ENT_HTML5) ?>
+
+ delivery address
+
+ = htmlspecialchars($user->getDeliveryAddress()->getStreet(), ENT_HTML5) ?>
+ = htmlspecialchars($user->getDeliveryAddress()->getZip(), ENT_HTML5) ?> = htmlspecialchars($user->getDeliveryAddress()->getCity(), ENT_HTML5) ?>