@@ -179,36 +179,36 @@ static PHP_METHOD(MongoDB_BSON_UTCDateTime, __construct)
179
179
return ;
180
180
}
181
181
182
- if (Z_TYPE_P (milliseconds ) == IS_OBJECT ) {
183
- if (instanceof_function (Z_OBJCE_P (milliseconds ), php_date_get_interface_ce ())) {
184
- php_phongo_utcdatetime_init_from_date (intern , Z_PHPDATE_P (milliseconds ));
185
- } else {
186
- phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT , "Expected instance of DateTimeInterface, %s given" , ZSTR_VAL (Z_OBJCE_P (milliseconds )-> name ));
182
+ switch (Z_TYPE_P (milliseconds )) {
183
+ case IS_OBJECT :
184
+ if (instanceof_function (Z_OBJCE_P (milliseconds ), php_date_get_interface_ce ())) {
185
+ php_phongo_utcdatetime_init_from_date (intern , Z_PHPDATE_P (milliseconds ));
186
+ } else {
187
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT , "Expected instance of DateTimeInterface, %s given" , ZSTR_VAL (Z_OBJCE_P (milliseconds )-> name ));
188
+ }
189
+ return ;
190
+
191
+ case IS_LONG :
192
+ php_phongo_utcdatetime_init (intern , Z_LVAL_P (milliseconds ));
193
+ return ;
194
+
195
+ case IS_DOUBLE : {
196
+ char tmp [24 ];
197
+ int tmp_len ;
198
+
199
+ tmp_len = snprintf (tmp , sizeof (tmp ), "%.0f" , Z_DVAL_P (milliseconds ) > 0 ? floor (Z_DVAL_P (milliseconds )) : ceil (Z_DVAL_P (milliseconds )));
200
+
201
+ php_phongo_utcdatetime_init_from_string (intern , tmp , tmp_len );
187
202
}
188
- return ;
189
- }
190
-
191
- if (Z_TYPE_P (milliseconds ) == IS_LONG ) {
192
- php_phongo_utcdatetime_init (intern , Z_LVAL_P (milliseconds ));
193
- return ;
194
- }
195
203
196
- if (Z_TYPE_P (milliseconds ) == IS_DOUBLE ) {
197
- char tmp [24 ];
198
- int tmp_len ;
204
+ return ;
199
205
200
- tmp_len = snprintf (tmp , sizeof (tmp ), "%.0f" , Z_DVAL_P (milliseconds ) > 0 ? floor (Z_DVAL_P (milliseconds )) : ceil (Z_DVAL_P (milliseconds )));
201
-
202
- php_phongo_utcdatetime_init_from_string (intern , tmp , tmp_len );
203
- return ;
204
- }
205
-
206
- if (Z_TYPE_P (milliseconds ) != IS_STRING ) {
207
- phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT , "Expected integer or string, %s given" , PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P (milliseconds ));
208
- return ;
206
+ case IS_STRING :
207
+ php_phongo_utcdatetime_init_from_string (intern , Z_STRVAL_P (milliseconds ), Z_STRLEN_P (milliseconds ));
208
+ return ;
209
209
}
210
210
211
- php_phongo_utcdatetime_init_from_string ( intern , Z_STRVAL_P ( milliseconds ), Z_STRLEN_P (milliseconds ));
211
+ phongo_throw_exception ( PHONGO_ERROR_INVALID_ARGUMENT , "Expected integer or string, %s given" , PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P (milliseconds ));
212
212
}
213
213
214
214
static PHP_METHOD (MongoDB_BSON_UTCDateTime , __set_state )
0 commit comments