Register
extends Model
in package
Register Class
Table of Contents
- $db : Database
- Contains the Database instance
- $user_email : string
- Contains the email of the new user
- $user_id : int
- Contains the ID of the new user
- $user_name : string
- Contains the user name of the new user
- $user_password : string
- Contains the password of the new user
- __construct() : mixed
- Constructor
- __destruct() : mixed
- Destructor
- checkEmail() : array<string|int, mixed>|null
- Check if the email exists
- checkIfPlanetExists() : bool
- Get planet by coords
- checkUser() : array<string|int, mixed>|null
- Check if the username exists
- createNewUser() : void
- Register a new user
- getNewUserData() : array<string|int, mixed>
- Get the new user ID
- createNewPlanet() : void
- Create a new planet
- setNewDb() : void
- Creates a new Database object
- updateUserPlanet() : void
- Assign the newly created planet to the newly registered user
Properties
$db
Contains the Database instance
protected
Database
$db
$user_email
Contains the email of the new user
private
string
$user_email
= ''
$user_id
Contains the ID of the new user
private
int
$user_id
= 0
$user_name
Contains the user name of the new user
private
string
$user_name
= ''
$user_password
Contains the password of the new user
private
string
$user_password
= ''
Methods
__construct()
Constructor
public
__construct() : mixed
Return values
mixed —__destruct()
Destructor
public
__destruct() : mixed
Return values
mixed —checkEmail()
Check if the email exists
public
checkEmail(string $email) : array<string|int, mixed>|null
Parameters
- $email : string
Return values
array<string|int, mixed>|null —checkIfPlanetExists()
Get planet by coords
public
checkIfPlanetExists(int $galaxy, int $system, int $planet) : bool
Parameters
- $galaxy : int
- $system : int
- $planet : int
Return values
bool —checkUser()
Check if the username exists
public
checkUser(string $user_name) : array<string|int, mixed>|null
Parameters
- $user_name : string
Return values
array<string|int, mixed>|null —createNewUser()
Register a new user
public
createNewUser(Users $user, array<string|int, mixed> $new_user_data, array<string|int, mixed> $coords) : void
Parameters
- $user : Users
- $new_user_data : array<string|int, mixed>
- $coords : array<string|int, mixed>
Return values
void —getNewUserData()
Get the new user ID
public
getNewUserData() : array<string|int, mixed>
Return values
array<string|int, mixed> —createNewPlanet()
Create a new planet
private
createNewPlanet(array<string|int, mixed> $coords, int $new_user_id) : void
Parameters
- $coords : array<string|int, mixed>
- $new_user_id : int
Return values
void —setNewDb()
Creates a new Database object
private
setNewDb() : void
Return values
void —updateUserPlanet()
Assign the newly created planet to the newly registered user
private
updateUserPlanet(array<string|int, mixed> $coords, int $new_user_id) : void
Parameters
- $coords : array<string|int, mixed>
- $new_user_id : int