Sapphire Documentation

Sapphire\User\User::class

class User


public static function ById(int $id): User | null - Returns user by id

public static function All(): array - Returns all users


public static function HasSession(): bool - Checks if user is logged

public static function SessionId(): int - Returns user id whose session is logged

public static function Session(): User - Returns current sessions user or unknown user (unlogged)

public static function ByCredential(string $credential): User | null - Returns user by credential (username or email)

public static function ByLogin(string $username, string $password): User | null - Returns user by login credentials (username and password)


public function __construct(int $id) - Constructs user

public function IsNew(): bool - Checks if user is new

public function IsSuperAdmin(): bool

public function IsAdmin(): bool

public function IsModerator(): bool

public function GetId(): int

public function GetUsername(): string

public function GetEmail(): string

public function GetRole(): string

public function GetCreatedAt(): string

public function IsGuest(): bool

public function GetAvatar(): string

public function AsJSONString(): string - Serialize object as json

public function Serialize(): array - Serialize object as array

public function Out(): void - Outputs user as string (echo to html)

public function Exists(): bool - Returns if user exists

public function Setup(): void - Setups user