ar_JO
5 years ago
ar_SA
5 years ago
at_AT
5 years ago
bg_BG
5 years ago
bn_BD
5 years ago
cs_CZ
5 years ago
da_DK
5 years ago
de_AT
5 years ago
de_CH
5 years ago
de_DE
5 years ago
el_CY
5 years ago
el_GR
5 years ago
en_AU
5 years ago
en_CA
5 years ago
en_GB
5 years ago
en_HK
5 years ago
en_IN
5 years ago
en_NG
5 years ago
en_NZ
5 years ago
en_PH
5 years ago
en_SG
5 years ago
en_UG
5 years ago
en_US
5 years ago
en_ZA
5 years ago
es_AR
5 years ago
es_ES
5 years ago
es_PE
5 years ago
es_VE
5 years ago
et_EE
5 years ago
fa_IR
5 years ago
fi_FI
5 years ago
fr_BE
5 years ago
fr_CA
5 years ago
fr_CH
5 years ago
fr_FR
5 years ago
he_IL
5 years ago
hr_HR
5 years ago
hu_HU
5 years ago
hy_AM
5 years ago
id_ID
5 years ago
is_IS
5 years ago
it_CH
5 years ago
it_IT
5 years ago
ja_JP
5 years ago
ka_GE
5 years ago
kk_KZ
5 years ago
ko_KR
5 years ago
lt_LT
5 years ago
lv_LV
5 years ago
me_ME
5 years ago
mn_MN
5 years ago
ms_MY
5 years ago
nb_NO
5 years ago
ne_NP
5 years ago
nl_BE
5 years ago
nl_NL
5 years ago
pl_PL
5 years ago
pt_BR
5 years ago
pt_PT
5 years ago
ro_MD
5 years ago
ro_RO
5 years ago
ru_RU
5 years ago
sk_SK
5 years ago
sl_SI
5 years ago
sr_Cyrl_RS
5 years ago
sr_Latn_RS
5 years ago
sr_RS
5 years ago
sv_SE
5 years ago
th_TH
5 years ago
tr_TR
5 years ago
uk_UA
5 years ago
vi_VN
5 years ago
zh_CN
5 years ago
zh_TW
5 years ago
Address.php
5 years ago
Barcode.php
5 years ago
Base.php
5 years ago
Biased.php
5 years ago
Color.php
5 years ago
Company.php
5 years ago
DateTime.php
5 years ago
File.php
5 years ago
HtmlLorem.php
5 years ago
Image.php
5 years ago
Internet.php
5 years ago
Lorem.php
5 years ago
Miscellaneous.php
5 years ago
Payment.php
5 years ago
Person.php
5 years ago
PhoneNumber.php
5 years ago
Text.php
5 years ago
UserAgent.php
5 years ago
Uuid.php
5 years ago
Address.php
140 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Faker\Provider; |
| 4 | |
| 5 | class Address extends Base |
| 6 | { |
| 7 | protected static $citySuffix = array('Ville'); |
| 8 | protected static $streetSuffix = array('Street'); |
| 9 | protected static $cityFormats = array( |
| 10 | '{{firstName}}{{citySuffix}}', |
| 11 | ); |
| 12 | protected static $streetNameFormats = array( |
| 13 | '{{lastName}} {{streetSuffix}}' |
| 14 | ); |
| 15 | protected static $streetAddressFormats = array( |
| 16 | '{{buildingNumber}} {{streetName}}' |
| 17 | ); |
| 18 | protected static $addressFormats = array( |
| 19 | '{{streetAddress}} {{postcode}} {{city}}', |
| 20 | ); |
| 21 | |
| 22 | protected static $buildingNumber = array('%#'); |
| 23 | protected static $postcode = array('#####'); |
| 24 | protected static $country = array(); |
| 25 | |
| 26 | /** |
| 27 | * @example 'town' |
| 28 | */ |
| 29 | public static function citySuffix() |
| 30 | { |
| 31 | return static::randomElement(static::$citySuffix); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @example 'Avenue' |
| 36 | */ |
| 37 | public static function streetSuffix() |
| 38 | { |
| 39 | return static::randomElement(static::$streetSuffix); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @example '791' |
| 44 | */ |
| 45 | public static function buildingNumber() |
| 46 | { |
| 47 | return static::numerify(static::randomElement(static::$buildingNumber)); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @example 'Sashabury' |
| 52 | */ |
| 53 | public function city() |
| 54 | { |
| 55 | $format = static::randomElement(static::$cityFormats); |
| 56 | |
| 57 | return $this->generator->parse($format); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @example 'Crist Parks' |
| 62 | */ |
| 63 | public function streetName() |
| 64 | { |
| 65 | $format = static::randomElement(static::$streetNameFormats); |
| 66 | |
| 67 | return $this->generator->parse($format); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @example '791 Crist Parks' |
| 72 | */ |
| 73 | public function streetAddress() |
| 74 | { |
| 75 | $format = static::randomElement(static::$streetAddressFormats); |
| 76 | |
| 77 | return $this->generator->parse($format); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @example 86039-9874 |
| 82 | */ |
| 83 | public static function postcode() |
| 84 | { |
| 85 | return static::toUpper(static::bothify(static::randomElement(static::$postcode))); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @example '791 Crist Parks, Sashabury, IL 86039-9874' |
| 90 | */ |
| 91 | public function address() |
| 92 | { |
| 93 | $format = static::randomElement(static::$addressFormats); |
| 94 | |
| 95 | return $this->generator->parse($format); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * @example 'Japan' |
| 100 | */ |
| 101 | public static function country() |
| 102 | { |
| 103 | return static::randomElement(static::$country); |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * @example '77.147489' |
| 108 | * @param float|int $min |
| 109 | * @param float|int $max |
| 110 | * @return float Uses signed degrees format (returns a float number between -90 and 90) |
| 111 | */ |
| 112 | public static function latitude($min = -90, $max = 90) |
| 113 | { |
| 114 | return static::randomFloat(6, $min, $max); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @example '86.211205' |
| 119 | * @param float|int $min |
| 120 | * @param float|int $max |
| 121 | * @return float Uses signed degrees format (returns a float number between -180 and 180) |
| 122 | */ |
| 123 | public static function longitude($min = -180, $max = 180) |
| 124 | { |
| 125 | return static::randomFloat(6, $min, $max); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * @example array('77.147489', '86.211205') |
| 130 | * @return array | latitude, longitude |
| 131 | */ |
| 132 | public static function localCoordinates() |
| 133 | { |
| 134 | return array( |
| 135 | 'latitude' => static::latitude(), |
| 136 | 'longitude' => static::longitude() |
| 137 | ); |
| 138 | } |
| 139 | } |
| 140 |