From 5b572724c6995b9784e2a126282e54a9e3dc4d3e Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 25 Jun 2012 18:02:46 +0100 Subject: [PATCH] Added latitude and longitude formatters to Address provider --- readme.md | 2 ++ src/Faker/Provider/Address.php | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/readme.md b/readme.md index 94f7dc1a..78f2926a 100644 --- a/readme.md +++ b/readme.md @@ -83,6 +83,8 @@ Each of the generator properties (like `name`, `address`, and `lorem`) are calle postcode // '17916' address // '8888 Cummings Vista Apt. 101, Susanbury, NY 95473' country // 'Falkland Islands (Malvinas)' + latitude // '77.147489' + longitude // '86.211205' ### `Faker\Provider\en_US\PhoneNumber` diff --git a/src/Faker/Provider/Address.php b/src/Faker/Provider/Address.php index 6c40000d..e4e6fab9 100644 --- a/src/Faker/Provider/Address.php +++ b/src/Faker/Provider/Address.php @@ -99,4 +99,19 @@ class Address extends \Faker\Provider\Base return static::randomElement(static::$country); } + /** + * @example '77.147489' + */ + public static function latitude() + { + return number_format(mt_rand(-180000000, 180000000)/1000000, 6); + } + + /** + * @example '86.211205' + */ + public static function longitude() + { + return number_format(mt_rand(-180000000, 180000000)/1000000, 6); + } } \ No newline at end of file