@@ -122,7 +122,7 @@ public function allocate()
122
122
$ this ->setOptions (self ::DEFAULT_OPTION );
123
123
$ this ->setTimezone (self ::DEFAULT_TZ );
124
124
125
- if (empty ($ id )) return ;
125
+ if (is_null ($ id )) return ;
126
126
127
127
if (!isset (Common::$ database ))
128
128
{
@@ -368,20 +368,6 @@ public static function generateVerifierToken(string $username, string $email)
368
368
return hash ('sha256 ' , $ digest );
369
369
}
370
370
371
- public static function findUserById (?int $ user_id )
372
- {
373
- if (is_null ($ user_id )) return null ;
374
-
375
- try
376
- {
377
- return new User ($ user_id );
378
- }
379
- catch (UserNotFoundException $ e )
380
- {
381
- return null ;
382
- }
383
- }
384
-
385
371
public static function &getAllUsers ($ order = null , $ limit = null , $ index = null )
386
372
{
387
373
if (!(is_numeric ($ limit ) || is_numeric ($ index ))) {
@@ -479,7 +465,7 @@ public function getId()
479
465
480
466
public function getName ()
481
467
{
482
- return ( is_null ( $ this ->display_name ) ? $ this ->username : $ this -> display_name ) ;
468
+ return $ this ->display_name ?? $ this ->username ;
483
469
}
484
470
485
471
public function getOption (int $ option )
@@ -511,9 +497,16 @@ public function getPasswordSalt()
511
497
512
498
public function getURI ()
513
499
{
514
- return Common::relativeUrlToAbsolute (
515
- '/user/ ' . $ this ->getId () . '/ ' . Common::sanitizeForUrl ($ this ->getName (), true )
516
- );
500
+ $ id = $ this ->getId ();
501
+
502
+ if (is_null ($ id ))
503
+ {
504
+ throw new UnexpectedValueException ('user id is null ' );
505
+ }
506
+
507
+ return Common::relativeUrlToAbsolute (sprintf (
508
+ '/user/%s/%s ' , $ id , Common::sanitizeForUrl ($ this ->getName (), true )
509
+ ));
517
510
}
518
511
519
512
public static function getUserCount ()
0 commit comments