Constants

MERCURY

MERCURY = [3.303E+23, 2439700.0]

VENUS

VENUS = [4.869E+24, 6051800.0]

EARTH

EARTH = [5.976E+24, 6378140.0]

MARS

MARS = [6.421E+23, 3397200.0]

JUPITER

JUPITER = [1.9E+27, 71492000.0]

SATURN

SATURN = [5.688E+26, 60268000.0]

URANUS

URANUS = [8.686E+25, 25559000.0]

NEPTUNE

NEPTUNE = [1.024E+26, 24746000.0]

G

G = 6.673E-11

Universal gravitational constant.

Properties

$name

$name : string

Type

string

$ordinal

$ordinal : int

Type

int

$values

$values : array<string,array<string,static>>

Type

array>

$allValuesLoaded

$allValuesLoaded : array<string,bool>

Type

array

$constants

$constants : array<string,array>

Type

array

$mass

$mass : float

Mass in kilograms.

Type

float

$radius

$radius : float

Radius in meters.

Type

float

Methods

__callStatic()

__callStatic(string  $name, array  $arguments) : static

Magic getter which forwards all calls to {@see self::valueOf()}.

Parameters

string $name
array $arguments

Returns

static —

valueOf()

valueOf(string  $name) : static

Returns an enum with the specified name.

The name must match exactly an identifier used to declare an enum in this type (extraneous whitespace characters are not permitted).

Parameters

string $name

Throws

\DASPRiD\Enum\Exception\IllegalArgumentException

if the enum has no constant with the specified name

Returns

static —

values()

values() : static[]

Obtains all possible types defined by this enum.

Returns

static[] —

name()

name() : string

Returns the name of this enum constant, exactly as declared in its enum declaration.

Most programmers should use the {@see \DASPRiD\Enum\self::__toString()} method in preference to this one, as the toString method may return a more user-friendly name. This method is designed primarily for use in specialized situations where correctness depends on getting the exact name, which will not vary from release to release.

Returns

string —

ordinal()

ordinal() : int

Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).

Most programmers will have no use for this method. It is designed for use by sophisticated enum-based data structures.

Returns

int —

compareTo()

compareTo(self  $other) : int

Compares this enum with the specified object for order.

Returns negative integer, zero or positive integer as this object is less than, equal to or greater than the specified object.

Enums are only comparable to other enums of the same type. The natural order implemented by this method is the order in which the constants are declared.

Parameters

self $other

Throws

\DASPRiD\Enum\Exception\MismatchException

if the passed enum is not of the same type

Returns

int —

__clone()

__clone() : mixed

Forbid cloning enums.

Throws

\DASPRiD\Enum\Exception\CloneNotSupportedException

Returns

mixed —

__sleep()

__sleep() : array

Forbid serializing enums.

Throws

\DASPRiD\Enum\Exception\SerializeNotSupportedException

Returns

array —

__wakeup()

__wakeup() : void

Forbid unserializing enums.

Throws

\DASPRiD\Enum\Exception\UnserializeNotSupportedException

__toString()

__toString() : string

Turns the enum into a string representation.

You may override this method to give a more user-friendly version.

Returns

string —

mass()

mass() : float

Returns

float —

radius()

radius() : float

Returns

float —

surfaceGravity()

surfaceGravity() : float

Returns

float —

surfaceWeight()

surfaceWeight(float  $otherMass) : float

Parameters

float $otherMass

Returns

float —

MERCURY()

MERCURY() : self

Returns

self —

VENUS()

VENUS() : self

Returns

self —

EARTH()

EARTH() : self

Returns

self —

MARS()

MARS() : self

Returns

self —

JUPITER()

JUPITER() : self

Returns

self —

SATURN()

SATURN() : self

Returns

self —

URANUS()

URANUS() : self

Returns

self —

NEPTUNE()

NEPTUNE() : self

Returns

self —

__construct()

__construct(float  $mass, float  $radius) : mixed

The constructor is private by default to avoid arbitrary enum creation.

When creating your own constructor for a parameterized enum, make sure to declare it as protected, so that the static methods are able to construct it. Avoid making it public, as that would allow creation of non-singleton enum instances.

Parameters

float $mass
float $radius

Returns

mixed —

createValue()

createValue(string  $name, int  $ordinal, array  $arguments) : static

Parameters

string $name
int $ordinal
array $arguments

Returns

static —

constants()

constants() : array

Returns

array —