public static function getById($userId, $cache = false) : Users
    {
        $options = null;
        $key = 'userInfo_' . $userId;

        if ($cache) {
            $options = ['cache' => ['lifetime' => 3600, 'key' => $key]];
        }

        if ($userData = Users::findFirstById($userId, $options)) {
            return $userData;
        } else {
            throw new Exception(_('The specified user does not exist in our database.'));
        }
    }
public static function getById($userId, $cache = false) : Users
    {
        $options = null;
        $key = 'userInfo_' . $userId;

        if ($cache) {
            $options = ['cache' => ['lifetime' => 3600, 'key' => $key]];
        }

        if ($userData = Users::findFirstById($userId, $options)) {
            return $userData;
        } else {
            throw new Exception(_('The specified user does not exist in our database.'));
        }
    }
public static function getById ( $ userId , $ cache = false ) : Users { $ options = null ; $ key = 'userInfo_' . $ userId ; if ( $ cache ) { $ options = [ 'cache' => [ 'lifetime' => 3600 , 'key' => $ key ] ] ; } if ( $ userData = Users :: findFirstById ( $ userId , $ options ) ) { return $ userData ; } else { throw new Exception ( _ ( 'The specified user does not exist in our database.' ) ) ; } }
get the user by its Id, we can specify the cache if we want to
we only get result if the user is active

@param int $userId
@param boolean $cache

@return User
get the user by its Id we can specify the cache if we want to we only get result if the user is active