Zed. The source code to build a world.

Location extends Entity
in package

Geo location class

This class contains properties to get, set or compare a location and explore the geo classes linked to.

It quickly allows to parse through the location classes in templates and controllers.

Tags
todo

Initialize $point3D from $body or $ship own locations

todo

Improve documentation (especially magic properties)

Table of Contents

Properties

$body  : Body
A body object
$place  : Place|null
A place object
$point3D  : Point3D|null
A point identified by x, y, z coordinates
$ship  : Ship
A ship object
$data  : array<string|int, mixed>
An array of strings containing location data.
$db  : DatabaseEngine

Methods

__construct()  : mixed
Initializes a new location instance
__get()  : mixed
Magic method called when a unknown property is get.
__set()  : mixed
Magic method called when a unknown property is set.
__toString()  : string
Represents the current location instance as a string
equals()  : bool
Checks if the place is equals at the specified expression or place
exists()  : bool
Checks if the place exists
getDatabase()  : DatabaseEngine
load_classes()  : mixed
Gets $place, $body and $ship instances if they're needed
setDatabase()  : void

Properties

$body

A body object

public Body $body = null

It contains a GeoBody value when the global location is a body ie if $this->data[0][0] == 'B'

Otherwise, its value is null.

$place

A place object

public Place|null $place = null

It contains a Place value when the global location is a place ie if $this->data[0][0] == 'B' && strlen($this->data[0]) == 9

Otherwise, its value is null.

$point3D

A point identified by x, y, z coordinates

public Point3D|null $point3D = null

$ship

A ship object

public Ship $ship = null

It contains a Ship value when the global location is a ship ie if $this->data[0][0] == 'S'

Otherwise, its value is null.

$data

An array of strings containing location data.

private array<string|int, mixed> $data

In the current class implementation, the first element is the global location and the second element is the local location.

Methods

__construct()

Initializes a new location instance

public __construct(DatabaseEngine $db[, string $global = null ][, string $local = null ]) : mixed
Parameters
$db : DatabaseEngine
$global : string = null
$local : string = null
Tags
todo

Improve local location handling

__get()

Magic method called when a unknown property is get.

public __get(mixed $variable) : mixed

Handles $global, $local, $type, $body_code, $ship_code, $place_code, $body_kind, $containsGlobalLocation, $containsLocalLocation.

Parameters
$variable : mixed

__set()

Magic method called when a unknown property is set.

public __set(mixed $variable, mixed $value) : mixed

Handles $global, $local, $type, $body_code, $ship_code, $place_code

Parameters
$variable : mixed
$value : mixed

__toString()

Represents the current location instance as a string

public __toString() : string
Return values
string

a string representing the current location

equals()

Checks if the place is equals at the specified expression or place

public equals(mixed $expression) : bool
Parameters
$expression : mixed
Tags
todo

Create a better set of rules to define when 2 locations are equal.

Return values
bool

true if the places are equals ; otherwise, false.

exists()

Checks if the place exists

public exists() : bool
Tags
todo

Handle alias

Return values
bool

true if the place exists ; otherwise, false.

getDatabase()

public getDatabase() : DatabaseEngine
Return values
DatabaseEngine

load_classes()

Gets $place, $body and $ship instances if they're needed

public load_classes() : mixed

setDatabase()

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

        
On this page

Search results