2
2
3
3
namespace MessageBird \Objects ;
4
4
5
+ use stdClass ;
6
+
5
7
/**
6
8
* Class Contact
7
9
*
@@ -65,16 +67,16 @@ class Contact extends Base
65
67
/**
66
68
* The hash of the group this contact belongs to.
67
69
*
68
- * @var array
70
+ * @var ?stdClass
69
71
*/
70
- protected $ groups = [] ;
72
+ protected $ groups = null ;
71
73
72
74
/**
73
75
* The hash with messages sent to contact.
74
76
*
75
- * @var array
77
+ * @var ?stdClass
76
78
*/
77
- protected $ messages = [] ;
79
+ protected $ messages = null ;
78
80
79
81
/**
80
82
* The date and time of the creation of the contact in RFC3339 format (Y-m-d\TH:i:sP)
@@ -100,12 +102,12 @@ public function getHref(): string
100
102
return $ this ->href ;
101
103
}
102
104
103
- public function getGroups (): array
105
+ public function getGroups (): stdClass
104
106
{
105
107
return $ this ->groups ;
106
108
}
107
109
108
- public function getMessages (): array
110
+ public function getMessages (): stdClass
109
111
{
110
112
return $ this ->messages ;
111
113
}
@@ -115,7 +117,7 @@ public function getCreatedDatetime(): string
115
117
return $ this ->createdDatetime ;
116
118
}
117
119
118
- public function getUpdatedDatetime (): string
120
+ public function getUpdatedDatetime (): ? string
119
121
{
120
122
return $ this ->updatedDatetime ;
121
123
}
@@ -126,16 +128,27 @@ public function getCustomDetails(): array
126
128
}
127
129
128
130
/**
131
+ * @deprecated 2.2.0 No longer used by internal code, please switch to {@see self::loadFromStdclass()}
132
+ *
129
133
* @param mixed $object
130
134
*/
131
- public function loadFromArray ($ object ): Contact
135
+ public function loadFromArray ($ object ): self
132
136
{
133
137
unset($ this ->custom1 , $ this ->custom2 , $ this ->custom3 , $ this ->custom4 );
134
-
138
+
135
139
return parent ::loadFromArray ($ object );
136
140
}
137
141
142
+ public function loadFromStdclass (stdClass $ object ): self
143
+ {
144
+ unset($ this ->custom1 , $ this ->custom2 , $ this ->custom3 , $ this ->custom4 );
145
+
146
+ return parent ::loadFromStdclass ($ object );
147
+ }
148
+
138
149
/**
150
+ * @deprecated 2.2.0 No longer used by internal code, please switch to {@see self::loadFromStdclassForGroups()}
151
+ *
139
152
* @param mixed $object
140
153
*
141
154
* @return $this ->object
@@ -154,4 +167,19 @@ public function loadFromArrayForGroups($object)
154
167
}
155
168
return $ object ;
156
169
}
170
+
171
+ public function loadFromStdclassForGroups (stdClass $ object )
172
+ {
173
+ parent ::loadFromStdclass ($ object );
174
+
175
+ if (!empty ($ object ->items )) {
176
+ foreach ($ object ->items as &$ item ) {
177
+ $ group = new Group ();
178
+ $ group ->loadFromStdclass ($ item );
179
+
180
+ $ item = $ group ;
181
+ }
182
+ }
183
+ return $ object ;
184
+ }
157
185
}
0 commit comments