Zed. The source code to build a world.

Ship extends Entity
in package

Ship class

This class maps the ship table.

It also provides helper methods to handle landing and fly out, or locate the ship.

The class also provides methods for the ship API.

Table of Contents

Properties

$api_key  : mixed
$description  : mixed
$id  : mixed
$lastError  : string
$location_global  : mixed
$location_local  : mixed
$name  : mixed
$db  : DatabaseEngine
$hashtable  : mixed

Methods

__construct()  : mixed
Initializes a new instance
__toString()  : the
Gets the ship code, as a string representation of the instance.
fly_in()  : mixed
Flies in the sip
fly_out()  : mixed
Flies out.
from_api_key()  : Ship
Loads a Ship object from its API key
get()  : Ship
Initializes a new Ship instance if needed or gets already available one.
get_code()  : string
Gets ship code, e.g. S00001
get_perso_from_session()  : mixed
Gets perso id from specified session
get_ships_at()  : array<string|int, Ship>
Get ships at specified location
getDatabase()  : DatabaseEngine
in_spatioport()  : bool
Determines if the ship is at a spatioport (or assimilated)
is_perso_authenticated()  : bool
Determines if a perso is authenticated to this ship
load_from_database()  : bool
Loads the object Ship (ie fill the properties) from the database
load_from_form()  : mixed
Loads the object Ship (ie fill the properties) from the $_POST array
request_perso_authenticate()  : mixed
Requests the specified perso to authenticate to this ship
request_perso_confirm_session()  : mixed
Requests the specified perso to confirm the ship API session
save_to_database()  : void
Saves to database
setDatabase()  : void
clean_ship_sessions()  : void
Cleans ship API temporary sessions

Properties

$api_key

public mixed $api_key

$description

public mixed $description

$lastError

public string $lastError = ""

$location_global

public mixed $location_global

$location_local

public mixed $location_local

$name

public mixed $name

$hashtable

private static mixed $hashtable = []

Methods

__construct()

Initializes a new instance

public __construct(DatabaseEngine $db[, int $id = null ]) : mixed
Parameters
$db : DatabaseEngine
$id : int = null

the primary key

__toString()

Gets the ship code, as a string representation of the instance.

public __toString() : the
Return values
the

ship's code

fly_in()

Flies in the sip

public fly_in([string $location_local = null ]) : mixed
Parameters
$location_local : string = null

the spatioport location

Tags
todo

Completes location global e.g. B00001 -> B00001003

fly_out()

Flies out.

public fly_out() : mixed

from_api_key()

Loads a Ship object from its API key

public static from_api_key(string $key) : Ship
Parameters
$key : string

API key GUID

Return values
Ship

the ship matching the API key

get()

Initializes a new Ship instance if needed or gets already available one.

public static get(DatabaseEngine $db[, mixed $data = null ]) : Ship
Parameters
$db : DatabaseEngine
$data : mixed = null

ship ID

Tags
deprecated

Use an entities repository

Return values
Ship

the ship instance

get_code()

Gets ship code, e.g. S00001

public get_code() : string
Return values
string

the ship code

get_perso_from_session()

Gets perso id from specified session

public get_perso_from_session(string $session_id) : mixed
Parameters
$session_id : string

a session ID provided by calling application

Return values
mixed

the session

get_ships_at()

Get ships at specified location

public static get_ships_at(DatabaseEngine $db, string $location_global[, string $location_local = null ]) : array<string|int, Ship>
Parameters
$db : DatabaseEngine
$location_global : string
$location_local : string = null
Tags
throws
Exception
Return values
array<string|int, Ship>

getDatabase()

public getDatabase() : DatabaseEngine
Return values
DatabaseEngine

in_spatioport()

Determines if the ship is at a spatioport (or assimilated)

public in_spatioport() : bool
Return values
bool

true if the ship is at a spatioport ; false if the ship is in space

is_perso_authenticated()

Determines if a perso is authenticated to this ship

public is_perso_authenticated(mixed $perso_data) : bool
Parameters
$perso_data : mixed

the perso id or name

Return values
bool

true if the specified perso name is authenticated to this ship ; otherwise, false.

load_from_database()

Loads the object Ship (ie fill the properties) from the database

public load_from_database() : bool
Return values
bool

load_from_form()

Loads the object Ship (ie fill the properties) from the $_POST array

public load_from_form() : mixed

request_perso_authenticate()

Requests the specified perso to authenticate to this ship

public request_perso_authenticate(mixed $perso_data) : mixed
Parameters
$perso_data : mixed

the perso id or name

request_perso_confirm_session()

Requests the specified perso to confirm the ship API session

public request_perso_confirm_session(string $session_id, mixed $perso_data) : mixed
Parameters
$session_id : string

a session ID provided by calling application

$perso_data : mixed

the perso id or name

save_to_database()

Saves to database

public save_to_database() : void

setDatabase()

public setDatabase(DatabaseEngine $db) : void
Parameters
$db : DatabaseEngine

clean_ship_sessions()

Cleans ship API temporary sessions

private clean_ship_sessions() : void

        
On this page

Search results