Address.php
5 years ago
Company.php
5 years ago
Internet.php
5 years ago
Payment.php
5 years ago
Person.php
5 years ago
PhoneNumber.php
5 years ago
Text.php
5 years ago
Address.php
141 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Faker\Provider\fr_CH; |
| 4 | |
| 5 | class Address extends \Faker\Provider\fr_FR\Address |
| 6 | { |
| 7 | protected static $buildingNumber = array('###', '##', '#', '#a', '#b', '#c'); |
| 8 | |
| 9 | protected static $streetPrefix = array('Rue', 'Rue', 'Chemin', 'Avenue', 'Boulevard', 'Place', 'Impasse'); |
| 10 | |
| 11 | protected static $postcode = array('####'); |
| 12 | |
| 13 | /** |
| 14 | * @link https://fr.wikipedia.org/wiki/Villes_de_Suisse |
| 15 | */ |
| 16 | protected static $cityNames = array( |
| 17 | 'Aarau', 'Aarberg', 'Aarburg', 'Agno', 'Aigle VD', 'Altdorf', 'Altstätten', 'Appenzell', 'Arbon', 'Ascona', 'Aubonne', 'Avenches', |
| 18 | 'Baden', 'Bad Zurzach', 'Bâle', 'Bellinzone', 'Berne', 'Beromünster', 'Berthoud', 'Biasca', 'Bienne', 'Bischofszell', 'Boudry', 'Bourg-Saint-Pierre', 'Bremgarten AG', 'Brigue', 'Brugg', 'Bulle', 'Bülach', |
| 19 | 'Cerlier', 'Châtel-Saint-Denis', |
| 20 | 'Coire', 'Conthey', 'Coppet', 'Cossonay', 'Croglio', 'Cudrefin', 'Cully', |
| 21 | 'Delémont', 'Diessenhofen', 'Échallens', 'Eglisau', 'Elgg', 'Estavayer-le-Lac', |
| 22 | 'Frauenfeld', 'Fribourg', |
| 23 | 'Genève', 'Glaris', 'Gordola', 'Grandcour', 'Grandson', 'Greifensee', 'Grüningen', 'Gruyères', |
| 24 | 'Hermance', 'Huttwil', |
| 25 | 'Ilanz', |
| 26 | 'Kaiserstuhl', 'Klingnau', |
| 27 | 'La Chaux-de-Fonds', 'La Neuveville', 'La Sarraz', 'La Tour-de-Peilz', 'La Tour-de-Trême', 'Le Landeron', 'Les Clées', 'Lachen', 'Langenthal', 'Laufon', 'Laufenburg', 'Laupen', 'Lausanne', 'Lenzburg', 'Loèche', 'Lichtensteig', 'Liestal', 'Locarno', 'Losone', 'Lugano', 'Lutry', 'Lucerne', |
| 28 | 'Maienfeld', 'Martigny', 'Mellingen', 'Mendrisio', 'Monthey', 'Morat', 'Morcote', 'Morges', 'Moudon', 'Moutier', 'Münchenstein', |
| 29 | 'Neuchâtel', 'Neunkirch', 'Nidau', 'Nyon', |
| 30 | 'Olten', 'Orbe', 'Orsières', |
| 31 | 'Payerne', 'Porrentruy', |
| 32 | 'Rapperswil', 'Regensberg', 'Rheinau', 'Rheineck', 'Rheinfelden', 'Riva San Vitale', 'Rolle', 'Romainmôtier', 'Romont FR', 'Rorschach', 'Rue', |
| 33 | 'Saillon', 'Saint-Maurice', 'Saint-Prex', 'Saint-Ursanne', 'Sala', 'Saint-Gall', 'Sargans', 'Sarnen', 'Schaffhouse', 'Schwytz', 'Sembrancher', 'Sempach', 'Sion', 'Soleure', 'Splügen', 'Stans', 'Steckborn', 'Stein am Rhein', 'Sursee', |
| 34 | 'Thoune', 'Thusis', |
| 35 | 'Unterseen', 'Uznach', |
| 36 | 'Valangin', 'Vevey', 'Villeneuve', 'Viège', |
| 37 | 'Waldenburg', 'Walenstadt', 'Wangen an der Aare', 'Werdenberg', 'Wiedlisbach', 'Wil', 'Willisau', 'Winterthour', |
| 38 | 'Yverdon-les-Bains', |
| 39 | 'Zofingue', 'Zoug', 'Zurich' |
| 40 | ); |
| 41 | |
| 42 | /** |
| 43 | * @link https://fr.wikipedia.org/wiki/Canton_suisse |
| 44 | */ |
| 45 | protected static $canton = array( |
| 46 | array('AG' => 'Argovie'), |
| 47 | array('AI' => 'Appenzell Rhodes-Intérieures'), |
| 48 | array('AR' => 'Appenzell Rhodes-Extérieures'), |
| 49 | array('BE' => 'Berne'), |
| 50 | array('BL' => 'Bâle-Campagne'), |
| 51 | array('BS' => 'Bâle-Ville'), |
| 52 | array('FR' => 'Fribourg'), |
| 53 | array('GE' => 'Genève'), |
| 54 | array('GL' => 'Glaris'), |
| 55 | array('GR' => 'Grisons'), |
| 56 | array('JU' => 'Jura'), |
| 57 | array('LU' => 'Lucerne'), |
| 58 | array('NE' => 'Neuchâtel'), |
| 59 | array('NW' => 'Nidwald'), |
| 60 | array('OW' => 'Obwald'), |
| 61 | array('SG' => 'Saint-Gall'), |
| 62 | array('SH' => 'Schaffhouse'), |
| 63 | array('SO' => 'Soleure'), |
| 64 | array('SZ' => 'Schwytz'), |
| 65 | array('TG' => 'Thurgovie'), |
| 66 | array('TI' => 'Tessin'), |
| 67 | array('UR' => 'Uri'), |
| 68 | array('VD' => 'Vaud'), |
| 69 | array('VS' => 'Valais'), |
| 70 | array('ZG' => 'Zoug'), |
| 71 | array('ZH' => 'Zurich') |
| 72 | ); |
| 73 | |
| 74 | protected static $cityFormats = array( |
| 75 | '{{cityName}}', |
| 76 | ); |
| 77 | |
| 78 | protected static $streetNameFormats = array( |
| 79 | '{{streetPrefix}} {{lastName}}', |
| 80 | '{{streetPrefix}} de {{cityName}}', |
| 81 | '{{streetPrefix}} de {{lastName}}' |
| 82 | ); |
| 83 | |
| 84 | protected static $streetAddressFormats = array( |
| 85 | '{{streetName}} {{buildingNumber}}', |
| 86 | ); |
| 87 | protected static $addressFormats = array( |
| 88 | "{{streetAddress}}\n{{postcode}} {{city}}", |
| 89 | ); |
| 90 | |
| 91 | /** |
| 92 | * Returns a random street prefix |
| 93 | * @example Rue |
| 94 | * @return string |
| 95 | */ |
| 96 | public static function streetPrefix() |
| 97 | { |
| 98 | return static::randomElement(static::$streetPrefix); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Returns a random city name. |
| 103 | * @example Luzern |
| 104 | * @return string |
| 105 | */ |
| 106 | public function cityName() |
| 107 | { |
| 108 | return static::randomElement(static::$cityNames); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Returns a canton |
| 113 | * @example array('BE' => 'Bern') |
| 114 | * @return array |
| 115 | */ |
| 116 | public static function canton() |
| 117 | { |
| 118 | return static::randomElement(static::$canton); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Returns the abbreviation of a canton. |
| 123 | * @return string |
| 124 | */ |
| 125 | public static function cantonShort() |
| 126 | { |
| 127 | $canton = static::canton(); |
| 128 | return key($canton); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Returns the name of canton. |
| 133 | * @return string |
| 134 | */ |
| 135 | public static function cantonName() |
| 136 | { |
| 137 | $canton = static::canton(); |
| 138 | return current($canton); |
| 139 | } |
| 140 | } |
| 141 |