@@ -16,16 +16,14 @@ class UserDataHelper
1616 private ?string $ country = null ;
1717
1818 /**
19- * @param string $email Valid email format
20- * @return int Cursor of array or -1 for invalid
19+ * @param string $email
20+ * @return bool
2121 */
2222 public function setEmail (string $ email ): bool
2323 {
24- // Sanitize & Validate email
2524 $ email = str_replace (" " , "" , mb_strtolower ($ email ));
26- if (!filter_var ($ email , FILTER_VALIDATE_EMAIL )) return false ; // Invalid email format
25+ if (!filter_var ($ email , FILTER_VALIDATE_EMAIL )) return false ;
2726
28- // Google Mail Sanitizer
2927 // https://support.google.com/mail/answer/7436150
3028 if (
3129 substr ($ email , -mb_strlen ("@gmail.com " )) == "@gmail.com " ||
@@ -42,13 +40,12 @@ public function setEmail(string $email): bool
4240 $ email = implode ("@ " , $ x );
4341 }
4442
45- // Sha256 encode
4643 $ this ->sha256_email_address = hash ("sha256 " , $ email );
4744 return true ;
4845 }
4946
5047 /**
51- * @param int $number fully international number (without dashes or plus) eg. \
48+ * @param int $number International number (without dashes and plus) eg. \
5249 * "+1-123-4567890" for USA or\
5350 * "+44-1234-5678900" for UK or\
5451 * "+45-12345678" for DK
@@ -65,48 +62,76 @@ public function setPhone(int $number): bool
6562 return true ;
6663 }
6764
65+ /**
66+ * @param string $firstName Users first name
67+ * @return bool
68+ */
6869 public function setFirstName (string $ firstName ): bool
6970 {
7071 if (empty ($ firstName )) return false ;
7172 $ this ->sha256_first_name = hash ("sha256 " , $ this ->strip ($ firstName , true ));
7273 return true ;
7374 }
7475
76+ /**
77+ * @param string $lastName Users last name
78+ * @return bool
79+ */
7580 public function setLastName (string $ lastName ): bool
7681 {
7782 if (empty ($ lastName )) return false ;
7883 $ this ->sha256_last_name = hash ("sha256 " , $ this ->strip ($ lastName , true ));
7984 return true ;
8085 }
8186
87+ /**
88+ * @param string $street Users street name
89+ * @return bool
90+ */
8291 public function setStreet (string $ street ): bool
8392 {
8493 if (empty ($ street )) return false ;
8594 $ this ->sha256_street = hash ("sha256 " , $ this ->strip ($ street ));
8695 return true ;
8796 }
8897
98+ /**
99+ * @param string $city Users city name
100+ * @return bool
101+ */
89102 public function setCity (string $ city ): bool
90103 {
91104 if (empty ($ city )) return false ;
92105 $ this ->city = $ this ->strip ($ city , true );
93106 return true ;
94107 }
95108
109+ /**
110+ * @param string $region Users region name
111+ * @return bool
112+ */
96113 public function setRegion (string $ region ): bool
97114 {
98115 if (empty ($ region )) return false ;
99116 $ this ->region = $ this ->strip ($ region , true );
100117 return true ;
101118 }
102119
120+ /**
121+ * @param string $postalCode Users postal code
122+ * @return bool
123+ */
103124 public function setPostalCode (string $ postalCode ): bool
104125 {
105126 if (empty ($ postalCode )) return false ;
106127 $ this ->postal_code = $ this ->strip ($ postalCode );
107128 return true ;
108129 }
109130
131+ /**
132+ * @param string $iso Users country (ISO)
133+ * @return bool
134+ */
110135 public function setCountry (string $ iso ): bool
111136 {
112137 if (!CountryIsoHelper::valid ($ iso )) {
0 commit comments