|
static | parseAndFormat (string $distance, string $unit=null, int $decimals=2) |
|
static | formatDistance (float $meters, string $unit=null, int $decimals=2) |
|
static | getUnitRatio (string $unit=null) |
|
static | getValidUnit (string $unit=null) |
|
static | parseDistance (string $distance) |
|
static | isDistance (string $distance) |
|
static | getUnits () |
|
Static class for distance validation and parsing. Internal representations are in meters.
GNU GPL v2+
- Author
- Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >
◆ formatDistance()
static Maps\Presentation\MapsDistanceParser::formatDistance |
( |
float |
$meters, |
|
|
string |
$unit = null , |
|
|
int |
$decimals = 2 |
|
) |
| |
|
static |
Formats a given distance in meters to a distance in an optionally specified notation.
◆ getUnitRatio()
static Maps\Presentation\MapsDistanceParser::getUnitRatio |
( |
string |
$unit = null | ) |
|
|
static |
Returns the unit to meter ratio in a safe way, by first resolving the unit.
◆ getUnits()
static Maps\Presentation\MapsDistanceParser::getUnits |
( |
| ) |
|
|
static |
Returns a list of all supported units.
◆ getValidUnit()
static Maps\Presentation\MapsDistanceParser::getValidUnit |
( |
string |
$unit = null | ) |
|
|
static |
Returns a valid unit. If the provided one is invalid, the default will be used.
◆ normalizeDistance()
static Maps\Presentation\MapsDistanceParser::normalizeDistance |
( |
string |
$distance | ) |
|
|
staticprotected |
Normalizes a potential distance by removing spaces and turning comma's into dots.
◆ parseDistance()
static Maps\Presentation\MapsDistanceParser::parseDistance |
( |
string |
$distance | ) |
|
|
static |
Parses a distance optionally containing a unit to a float value in meters.
- Parameters
-
- Returns
- float|false The distance in meters or false on failure
The documentation for this class was generated from the following file: