@@ -122,7 +122,7 @@ public function allocate()
122122 $ this ->setOptions (self ::DEFAULT_OPTION );
123123 $ this ->setTimezone (self ::DEFAULT_TZ );
124124
125- if (empty ($ id )) return ;
125+ if (is_null ($ id )) return ;
126126
127127 if (!isset (Common::$ database ))
128128 {
@@ -368,20 +368,6 @@ public static function generateVerifierToken(string $username, string $email)
368368 return hash ('sha256 ' , $ digest );
369369 }
370370
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-
385371 public static function &getAllUsers ($ order = null , $ limit = null , $ index = null )
386372 {
387373 if (!(is_numeric ($ limit ) || is_numeric ($ index ))) {
@@ -479,7 +465,7 @@ public function getId()
479465
480466 public function getName ()
481467 {
482- return ( is_null ( $ this ->display_name ) ? $ this ->username : $ this -> display_name ) ;
468+ return $ this ->display_name ?? $ this ->username ;
483469 }
484470
485471 public function getOption (int $ option )
@@ -511,9 +497,16 @@ public function getPasswordSalt()
511497
512498 public function getURI ()
513499 {
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+ ));
517510 }
518511
519512 public static function getUserCount ()
0 commit comments