@@ -260,17 +260,13 @@ public static function selectMessages($limit = null)
260
260
/**
261
261
* Convert from unix timestamp to timestamp
262
262
*
263
- * @param int $time Unix timestamp (if null , current timestamp is used)
263
+ * @param int $time Unix timestamp (if empty , current timestamp is used)
264
264
*
265
265
* @return string
266
266
*/
267
267
protected static function getTimestamp ($ time = null )
268
268
{
269
- if ($ time === null ) {
270
- $ time = time ();
271
- }
272
-
273
- return date ('Y-m-d H:i:s ' , $ time );
269
+ return date ('Y-m-d H:i:s ' , $ time ?: time ());
274
270
}
275
271
276
272
/**
@@ -362,7 +358,7 @@ public static function insertTelegramUpdate(
362
358
* @return bool If the insert was successful
363
359
* @throws TelegramException
364
360
*/
365
- public static function insertUser (User $ user , $ date , Chat $ chat = null )
361
+ public static function insertUser (User $ user , $ date = null , Chat $ chat = null )
366
362
{
367
363
if (!self ::isDbConnected ()) {
368
364
return false ;
@@ -389,6 +385,7 @@ public static function insertUser(User $user, $date, Chat $chat = null)
389
385
$ sth ->bindValue (':first_name ' , $ user ->getFirstName ());
390
386
$ sth ->bindValue (':last_name ' , $ user ->getLastName ());
391
387
$ sth ->bindValue (':language_code ' , $ user ->getLanguageCode ());
388
+ $ date = $ date ?: self ::getTimestamp ();
392
389
$ sth ->bindValue (':created_at ' , $ date );
393
390
$ sth ->bindValue (':updated_at ' , $ date );
394
391
@@ -429,7 +426,7 @@ public static function insertUser(User $user, $date, Chat $chat = null)
429
426
* @return bool If the insert was successful
430
427
* @throws TelegramException
431
428
*/
432
- public static function insertChat (Chat $ chat , $ date , $ migrate_to_chat_id = null )
429
+ public static function insertChat (Chat $ chat , $ date = null , $ migrate_to_chat_id = null )
433
430
{
434
431
if (!self ::isDbConnected ()) {
435
432
return false ;
@@ -466,6 +463,7 @@ public static function insertChat(Chat $chat, $date, $migrate_to_chat_id = null)
466
463
$ sth ->bindValue (':title ' , $ chat ->getTitle ());
467
464
$ sth ->bindValue (':username ' , $ chat ->getUsername ());
468
465
$ sth ->bindValue (':all_members_are_administrators ' , $ chat ->getAllMembersAreAdministrators (), PDO ::PARAM_INT );
466
+ $ date = $ date ?: self ::getTimestamp ();
469
467
$ sth ->bindValue (':created_at ' , $ date );
470
468
$ sth ->bindValue (':updated_at ' , $ date );
471
469
0 commit comments