PHP Class Treffynnon\Navigator\Coordinate

Show file Open project: treffynnon/navigator Class Usage Examples

Protected Properties

Property Type Description
$coordinate float The radian value of the supplied coordinate
$parser ParserInterface Parser object to use when converting a value to radians and back again

Public Methods

Method Description
__construct ( string | float $coord = null, Treffynnon\Navigator\Coordinate\ParserInterface $parser = null ) Setup a new coordinate
__toString ( ) : string Used when a coordinate value is used as a string. This uses the parser to output a human readable format converted from the radian value held in $this->coordinate
get ( ) : float Get a coordinates radian value
getParser ( ) : ParserInterface Get the parser that is currently in use for this coordinate
guessParser ( float | string $coord ) : Treffynnon\Navigator\Coordinate\DecimalParser | DmsParser Guess the correct parser for a given coordinate
set ( float $coord ) Sets the coordinate using the parser to a radian value
setParser ( Treffynnon\Navigator\Coordinate\ParserInterface $parser ) Set the parser that should be used to manage this coordinate

Method Details

__construct() public method

Setup a new coordinate
public __construct ( string | float $coord = null, Treffynnon\Navigator\Coordinate\ParserInterface $parser = null )
$coord string | float
$parser Treffynnon\Navigator\Coordinate\ParserInterface

__toString() public method

Used when a coordinate value is used as a string. This uses the parser to output a human readable format converted from the radian value held in $this->coordinate
public __toString ( ) : string
return string

get() public method

Get a coordinates radian value
public get ( ) : float
return float

getParser() public method

Get the parser that is currently in use for this coordinate
public getParser ( ) : ParserInterface
return ParserInterface

guessParser() public method

Guess the correct parser for a given coordinate
public guessParser ( float | string $coord ) : Treffynnon\Navigator\Coordinate\DecimalParser | DmsParser
$coord float | string
return Treffynnon\Navigator\Coordinate\DecimalParser | Treffynnon\Navigator\Coordinate\DmsParser

set() public method

Sets the coordinate using the parser to a radian value
public set ( float $coord )
$coord float

setParser() public method

Set the parser that should be used to manage this coordinate
public setParser ( Treffynnon\Navigator\Coordinate\ParserInterface $parser )
$parser Treffynnon\Navigator\Coordinate\ParserInterface

Property Details

$coordinate protected property

The radian value of the supplied coordinate
protected float $coordinate
return float

$parser protected property

Parser object to use when converting a value to radians and back again
protected ParserInterface $parser
return ParserInterface