| 1 | # automatically generated file, don't edit | ||||||||||
| 2 | |||||||||||
| 3 | |||||||||||
| 4 | |||||||||||
| 5 | # Copyright 2026 David Cantrell, derived from data from libphonenumber | ||||||||||
| 6 | # http://code.google.com/p/libphonenumber/ | ||||||||||
| 7 | # | ||||||||||
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| 9 | # you may not use this file except in compliance with the License. | ||||||||||
| 10 | # You may obtain a copy of the License at | ||||||||||
| 11 | # | ||||||||||
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| 13 | # | ||||||||||
| 14 | # Unless required by applicable law or agreed to in writing, software | ||||||||||
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| 17 | # See the License for the specific language governing permissions and | ||||||||||
| 18 | # limitations under the License. | ||||||||||
| 19 | package Number::Phone::StubCountry::CH; | ||||||||||
| 20 | 2 | ▶ | use base qw(Number::Phone::StubCountry); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 2 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 2 | our $VERSION = 1.20260904101548; | |||||||||
| 26 | |||||||||||
| 27 | 2 | my $formatters = [ | |||||||||
| 28 | { | ||||||||||
| 29 | 'format' => '$1 $2 $3', | ||||||||||
| 30 | 'leading_digits' => ' | ||||||||||
| 31 | 8[047]| | ||||||||||
| 32 | 90 | ||||||||||
| 33 | ', | ||||||||||
| 34 | 'national_rule' => '0$1', | ||||||||||
| 35 | 'pattern' => '(\\d{3})(\\d{3})(\\d{3})' | ||||||||||
| 36 | }, | ||||||||||
| 37 | { | ||||||||||
| 38 | 'format' => '$1 $2 $3 $4', | ||||||||||
| 39 | 'leading_digits' => ' | ||||||||||
| 40 | [2-79]| | ||||||||||
| 41 | 81 | ||||||||||
| 42 | ', | ||||||||||
| 43 | 'national_rule' => '0$1', | ||||||||||
| 44 | 'pattern' => '(\\d{2})(\\d{3})(\\d{2})(\\d{2})' | ||||||||||
| 45 | }, | ||||||||||
| 46 | { | ||||||||||
| 47 | 'format' => '$1 $2 $3 $4 $5', | ||||||||||
| 48 | 'leading_digits' => '8', | ||||||||||
| 49 | 'national_rule' => '0$1', | ||||||||||
| 50 | 'pattern' => '(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})' | ||||||||||
| 51 | } | ||||||||||
| 52 | ]; | ||||||||||
| 53 | |||||||||||
| 54 | 2 | my $validators = { | |||||||||
| 55 | 'fixed_line' => ' | ||||||||||
| 56 | (?: | ||||||||||
| 57 | 2[12467]| | ||||||||||
| 58 | 3[1-4]| | ||||||||||
| 59 | 4[134]| | ||||||||||
| 60 | 5[256]| | ||||||||||
| 61 | 6[12]| | ||||||||||
| 62 | [7-9]1 | ||||||||||
| 63 | )\\d{7} | ||||||||||
| 64 | ', | ||||||||||
| 65 | 'geographic' => ' | ||||||||||
| 66 | (?: | ||||||||||
| 67 | 2[12467]| | ||||||||||
| 68 | 3[1-4]| | ||||||||||
| 69 | 4[134]| | ||||||||||
| 70 | 5[256]| | ||||||||||
| 71 | 6[12]| | ||||||||||
| 72 | [7-9]1 | ||||||||||
| 73 | )\\d{7} | ||||||||||
| 74 | ', | ||||||||||
| 75 | 'mobile' => ' | ||||||||||
| 76 | (?: | ||||||||||
| 77 | 6[89]| | ||||||||||
| 78 | 7[235-9] | ||||||||||
| 79 | )\\d{7} | ||||||||||
| 80 | ', | ||||||||||
| 81 | 'pager' => '74[0248]\\d{6}', | ||||||||||
| 82 | 'personal_number' => '878\\d{6}', | ||||||||||
| 83 | 'specialrate' => '(84[0248]\\d{6})|(90[016]\\d{6})|(5[18]\\d{7})', | ||||||||||
| 84 | 'toll_free' => '800\\d{6}', | ||||||||||
| 85 | 'voip' => '' | ||||||||||
| 86 | }; | ||||||||||
| 87 | 2 | my %areanames = (); | |||||||||
| 88 | 2 | $areanames{it} = {"4161", "Basilea", | |||||||||
| 89 | "4132", "Bienne\/Neuchâtel\/Soletta\/Giura", | ||||||||||
| 90 | "4126", "Friburgo", | ||||||||||
| 91 | "4171", "San\ Gallo", | ||||||||||
| 92 | "4122", "Ginevra", | ||||||||||
| 93 | "4131", "Berna", | ||||||||||
| 94 | "4143", "Zurigo", | ||||||||||
| 95 | "4141", "Lucerna", | ||||||||||
| 96 | "4181", "Coira", | ||||||||||
| 97 | "4144", "Zurigo", | ||||||||||
| 98 | "4121", "Losanna",}; | ||||||||||
| 99 | 2 | $areanames{en} = {"4127", "Sion", | |||||||||
| 100 | "4126", "Fribourg", | ||||||||||
| 101 | "4161", "Basel", | ||||||||||
| 102 | "4132", "Bienne\/Neuchâtel\/Soleure\/Jura", | ||||||||||
| 103 | "4122", "Geneva", | ||||||||||
| 104 | "4191", "Bellinzona", | ||||||||||
| 105 | "4171", "St\.\ Gallen", | ||||||||||
| 106 | "4155", "Rapperswil", | ||||||||||
| 107 | "4124", "Yverdon\/Aigle", | ||||||||||
| 108 | "4162", "Olten", | ||||||||||
| 109 | "4131", "Berne", | ||||||||||
| 110 | "4141", "Lucerne", | ||||||||||
| 111 | "4133", "Thun", | ||||||||||
| 112 | "4143", "Zurich", | ||||||||||
| 113 | "4181", "Chur", | ||||||||||
| 114 | "4152", "Winterthur", | ||||||||||
| 115 | "4121", "Lausanne", | ||||||||||
| 116 | "4156", "Baden", | ||||||||||
| 117 | "4144", "Zurich", | ||||||||||
| 118 | "4134", "Burgdorf\/Langnau\ i\.E\.",}; | ||||||||||
| 119 | 2 | $areanames{fr} = {"4161", "Bâle", | |||||||||
| 120 | "4171", "St\.\ Gall", | ||||||||||
| 121 | "4122", "Genève", | ||||||||||
| 122 | "4152", "Winterthour", | ||||||||||
| 123 | "4181", "Coire", | ||||||||||
| 124 | "4133", "Thoune",}; | ||||||||||
| 125 | 2 | $areanames{de} = {"4132", "Biel\/Neuenburg\/Solothurn\/Jura", | |||||||||
| 126 | "4127", "Sitten", | ||||||||||
| 127 | "4126", "Freiburg", | ||||||||||
| 128 | "4122", "Genf", | ||||||||||
| 129 | "4141", "Luzern", | ||||||||||
| 130 | "4131", "Bern", | ||||||||||
| 131 | "4143", "Zürich", | ||||||||||
| 132 | "4144", "Zürich",}; | ||||||||||
| 133 | 2 | my $timezones = { | |||||||||
| 134 | '' => [ | ||||||||||
| 135 | 'Europe/Zurich' | ||||||||||
| 136 | ] | ||||||||||
| 137 | }; | ||||||||||
| 138 | |||||||||||
| 139 | 25 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 140 | 25 | my $class = shift; | |||||||||
| 141 | 25 | my $number = shift; | |||||||||
| 142 | 25 | $number =~ s/(^\+41|\D)//g; | |||||||||
| 143 | 25 | my $self = bless({ country_code => '41', number => $number, formatters => $formatters, validators => $validators, timezones => $timezones, areanames => \%areanames}, $class); | |||||||||
| 144 | 25 | ▶ | return $self if ($self->is_valid()); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 145 | 1 | $number =~ s/^(?:0)//; | |||||||||
| 146 | 1 | $self = bless({ country_code => '41', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class); | |||||||||
| 147 | 1 | ▶ | return $self->is_valid() ? $self : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | } | ||||||||||
| 149 | 2 | 1; | |||||||||