| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## URI::tel - ~/lib/URI/tel.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.800.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2019 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2016/02/12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2019/08/30 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | package URI::tel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use parent 'URI'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | our( $VERSION, $VERBOSE, $DEBUG, $ERROR ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | our( $RESERVED, $MARK, $UNRESERVED, $PCT_ENCODED, $URIC, $ALPHA, $DIGIT, $ALPHANUM, $HEXDIG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | our( $PARAM_UNRESERVED, $VISUAL_SEPARATOR, $PHONEDIGIT, $GLOBAL_NUMBER_DIGITS, $PARAMCHAR, $DOMAINLABEL, $TOPLABEL, $DOMAINNAME, $DESCRIPTOR, $PNAME, $PVALUE, $PARAMETER, $EXTENSION, $ISDN_SUBADDRESS, $CONTEXT, $PAR, $PHONEDIGIT_HEX, $GLOBAL_NUMBER, $LOCAL_NUMBER, $OTHER, $TEL_SUBSCRIBER, $TEL_URI ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | our( $COUNTRIES, $IDD_RE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | $VERSION = 'v0.800.1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | use overload ('""' => 'as_string', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | '==' => sub { _obj_eq(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | '!=' => sub { !_obj_eq(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | fallback => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | #$RESERVED = qr{[\[\;\/\?\:\@\&\=\+\$\,\[\]]+}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | $RESERVED = q{[;/?:@&=+$,[]+}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | $MARK = q{-_.!~*'()}; #'; emacs | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | $UNRESERVED = qq{A-Za-z0-9\Q$MARK\E}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ## "%" HEXDIG HEXDIG | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | $PCT_ENCODED = qr{\%[0-9A-Fa-f]{2}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | #$URIC = quotemeta( $RESERVED ) . $UNRESERVED . "%"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | $URIC = qr{(?:[\Q$RESERVED\E]+|[$UNRESERVED]+|(?:$PCT_ENCODED)+)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # $ALPHA = qr{A-Za-z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # $DIGIT = qr{\d}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | $ALPHA = qr{A-Za-z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | $DIGIT = qq{0-9}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # $ALPHANUM = qr{A-Za-z\d}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | $ALPHANUM = qq{A-Za-z0-9}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # $HEXDIG = qr{\dA-F}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | $HEXDIG = qr{\dA-F}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # $PARAM_UNRESERVED = qr{[\[\]\/\:\&\+\$]+}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | $PARAM_UNRESERVED = q{[]/:&+$}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | $VISUAL_SEPARATOR = q(-.()); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ## DIGIT / [ visual-separator ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # $PHONEDIGIT = qr{$DIGIT\Q$VISUAL_SEPARATOR\E}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | $PHONEDIGIT = qq{$DIGIT\Q$VISUAL_SEPARATOR\E}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ## "+" *phonedigit DIGIT *phonedigit | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | $GLOBAL_NUMBER_DIGITS = qr{\+[$PHONEDIGIT]*[$DIGIT]+[$PHONEDIGIT]*}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ## param-unreserved / unreserved / pct-encoded | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | $PARAMCHAR = qr{(?:[\Q$PARAM_UNRESERVED\E]+|[$UNRESERVED]+|(?:$PCT_ENCODED)+)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ## alphanum / alphanum *( alphanum / "-" ) alphanum | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | $DOMAINLABEL = qr{(?:[$ALPHANUM]+|[$ALPHANUM]+(?:[$ALPHANUM\-]+)*[$ALPHANUM]+)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ## ALPHA / ALPHA *( alphanum / "-" ) alphanum | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | $TOPLABEL = qr{(?:[$ALPHA]+|[$ALPHA]+[$ALPHANUM\-]*[$ALPHANUM]+)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ## *( domainlabel "." ) toplabel [ "." ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | $DOMAINNAME = qr{(?:$DOMAINLABEL\.)*(?:$TOPLABEL\.?)+}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ## domainname / global-number-digits | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | $DESCRIPTOR = qr{(?:$DOMAINNAME|$GLOBAL_NUMBER_DIGITS)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ## 1*( alphanum / "-" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | $PNAME = qr{[$ALPHANUM\-]+}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ## 1*paramchar | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | $PVALUE = qr{(?:$PARAMCHAR)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ## ";" pname ["=" pvalue ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | $PARAMETER = qr{\;$PNAME=$PVALUE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ## ";ext=" 1*phonedigit | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ##$EXTENSION = qr{\;ext=[$PHONEDIGIT]+}msxi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ## Tweaking the rfc regular expression to add often used extension format | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ## See: https://discussions.apple.com/thread/1635858?start=0&tstart=0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ## or | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ## http://stackoverflow.com/questions/2403767/string-format-phone-numbers-with-extension | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | $EXTENSION = qr{(?:[\;\,]?ext[\=\.]?|x)[$PHONEDIGIT]+}msxi; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ## ";isub=" 1*uric | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | $ISDN_SUBADDRESS = qr{\;isub=$URIC}msxi; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ## ";phone-context=" descriptor | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | $CONTEXT = qr{\;phone-context=$DESCRIPTOR}msxi; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ## parameter / extension / isdn-subaddress | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | $PAR = qr{(?:(?:($PARAMETER)|($EXTENSION)|($ISDN_SUBADDRESS)))+}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ## HEXDIG / "*" / "#" / [ visual-separator ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | $PHONEDIGIT_HEX = qr{[$HEXDIG\*\#$VISUAL_SEPARATOR]+}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ## *phonedigit-hex (HEXDIG / "*" / "#")*phonedigit-hex | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | $LOCAL_NUMBER_DIGITS = qr{(?:$PHONEDIGIT_HEX)?[$HEXDIG\*\#]+(?:$PHONEDIGIT_HEX)?}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ## global-number-digits *par => "+" *phonedigit DIGIT *phonedigit | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | $GLOBAL_NUMBER = qr{($GLOBAL_NUMBER_DIGITS)($PAR)*}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ## local-number-digits *par context *par | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | $LOCAL_NUMBER = qr{($LOCAL_NUMBER_DIGITS)($PAR)*($CONTEXT)($PAR)*}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ## This is a non-rfc standard requirement, but a necessity to catch local number with no context | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ## such as 03-1234-5678 plain and simple | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 3 | $OTHER = qr{(\+?[$PHONEDIGIT]*[$DIGIT]+[$PHONEDIGIT]*)($PAR)*}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ## Like +1-800-LAWYR-UP => +1-800-52997-87 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | $VANITY = qr{(\+?[$PHONEDIGIT]*[A-Z0-9\Q$VISUAL_SEPARATOR\E]+[$PHONEDIGIT]*)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | $TEL_SUBSCRIBER = qr{(?:$VANITY|$GLOBAL_NUMBER|$LOCAL_NUMBER|$OTHER)}xs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ##$TEL_SUBSCRIBER = qr{(?:$GLOBAL_NUMBER)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | $TEL_URI = qr{(?:tel\:)?$TEL_SUBSCRIBER}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # https://tools.ietf.org/search/rfc3966#section-3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | $COUNTRIES = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | sub _init | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | my $class = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my( $str, $scheme ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # find all funny characters and encode the bytes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $str = $class->_uric_escape( $str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | $str = "$scheme:$str" unless $str =~ /^[a-zA-Z][a-zA-Z0-9.+\-]*:/o || | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$str =~ /^[a-zA-Z][a-zA-Z0-9.+\-]*:/o or $class->_no_scheme_ok
MC/DC0%0/2
$str =~ /^[a-zA-Z][a-zA-Z0-9.+\-]*:/o or $class->_no_scheme_ok
$str =~ /^[a-zA-Z][a-zA-Z0-9.+\-]*:/o
$class->_no_scheme_ok
Truth table0%0/3
A or B
A= $str =~ /^[a-zA-Z][a-zA-Z0-9.+\-]*:/oB= $class->_no_scheme_ok
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | $class->_no_scheme_ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | #my $self = bless \$str, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | #$self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return( $class->new( $str ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 290 | ▶ | my $this = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=32 SCAR=34.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 290 | my $str = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 290 | ▶ | my $class = ref( $this ) || $this; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table66%2/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 290 | my $orig = $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 290 | $str =~ s/[[:blank:]]+//gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 290 | my $temp = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 290 | my @matches = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 290 | my @names = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 290 | ▶ | if( @matches = $str =~ /^((?:tel\:)?$GLOBAL_NUMBER)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 262 | @names = qw( all subscriber params last_param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 262 | $temp->{ 'type' } = 'global'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | elsif( @matches = $str =~ /^((?:tel\:)?$LOCAL_NUMBER)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | $temp->{ 'type' } = 'local'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 5 | @names = qw( all subscriber params1 last_param1 ignore5 ignore6 context params2 last_param2 ignore10 ignore11 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 5 | ▶ | $temp->{ '_has_context_param' } = 1 if( length( $matches[6] ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | $temp->{ 'local_number' } = $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | $temp->{ 'local_number' } =~ s/^tel\://; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ## e.g. 911, 110 or just ordinary local phones like 03-1234-5678 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | elsif( @matches = $str =~ /^((?:tel\:)?$OTHER)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 19 | $temp->{ 'type' } = 'other'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 19 | @names = qw( all subscriber params ignore4 last_param ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ## e.g. +1-800-LAWYR-UP | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | elsif( @matches = $str =~ /^((?:tel\:)?$VANITY)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | $temp->{ 'type' } = 'vanity'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | @names = qw( all subscriber ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | $ERROR = "Unknown telephone number '$str'."; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | warn( $ERROR ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ## The component name for each match | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 290 | @$temp{ @names } = @matches; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 290 | ▶ | $temp->{ 'params' } = $temp->{ 'params1' } ? $temp->{ 'params1' } : $temp->{ 'params2' } if( !length( $temp->{ 'params' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 290 | $temp->{ 'context' } =~ s/;[^=]+=(.*?)$/$1/gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 290 | ▶ | if( $str =~ /^(?:tel\:)?\+/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 263 | $temp->{ 'intl_code' } = $this->_extract_intl_code( $str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ▶ | elsif( $temp->{ 'context' } && | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$temp->{"context"} and not $temp->{"context"} =~ /^[a-zA-Z]/ and substr($temp->{"context"}, 0, 1) eq "+"
$temp->{"context"} and not $temp->{"context"} =~ /^[a-zA-Z]/
MC/DC66%2/3
$temp->{"context"} and not $temp->{"context"} =~ /^[a-zA-Z]/ and substr($temp->{"context"}, 0, 1) eq "+"
$temp->{"context"}
not $temp->{"context"} =~ /^[a-zA-Z]/
substr($temp->{"context"}, 0, 1) eq "+"
Truth table75%3/4
A and not(B) and C
A= $temp->{"context"}B= not $temp->{"context"} =~ /^[a-zA-Z]/C= substr($temp->{"context"}, 0, 1) eq "+"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | $temp->{ 'context' } !~ /^[a-zA-Z]/ && | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | substr( $temp->{ 'context' }, 0, 1 ) eq '+' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | $temp->{ 'intl_code' } = $this->_extract_intl_code( $temp->{ 'context' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ## We flag it as extracted from context, because we do not want to prepend the subscriber number with it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ## It's just too dangerous as we cannot tell the subscriber number is actually a proper number that can be dialed from outside e.g. 911 or 110 are emergency number who may heva a context with international code | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ## However, if the international code was provided by the user then that's his responsibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ## If the user wants to just provide some context, then better to use context() instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ## Knowing the international code helps getting some other useful information, but it should not necessarily affect the format of the number | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | $temp->{ '_intl_code_from_context' } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 290 | ▶ | $temp->{ 'context' } = '+' . $temp->{ 'intl_code' } if( !length( $temp->{ 'context' } ) && length( $temp->{ 'intl_code' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not length $temp->{"context"} and length $temp->{"intl_code"}
MC/DC100%2/2
not length $temp->{"context"} and length $temp->{"intl_code"}
not length $temp->{"context"}
length $temp->{"intl_code"}
Truth table100%3/3
not(A) and B
A= not length $temp->{"context"}B= length $temp->{"intl_code"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 290 | ▶ | if( $temp->{ 'type' } eq 'global' && $temp->{ 'intl_code' } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$temp->{"type"} eq "global" and $temp->{"intl_code"}
MC/DC50%1/2
$temp->{"type"} eq "global" and $temp->{"intl_code"}
$temp->{"type"} eq "global"
$temp->{"intl_code"}
Truth table66%2/3
A and B
A= $temp->{"type"} eq "global"B= $temp->{"intl_code"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 262 | $temp->{ 'local_number' } = $this->_extract_local_number( $temp->{ 'intl_code' }, $temp->{ 'subscriber' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | my $hash = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 'original' => ( $orig ne $str ) ? $orig : $temp->{ 'all' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 'is_global' => $temp->{ 'type' } eq 'global' ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 'is_local' => ( $temp->{ 'type' } eq 'local' or $temp->{ 'type' } eq 'other' ) ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 'is_other' => $temp->{ 'type' } eq 'other' ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 'is_vanity' => $temp->{ 'type' } eq 'vanity' ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 'subscriber' => $temp->{ 'subscriber' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 'params' => $temp->{ 'params' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 'last_param' => $temp->{ 'last_param' } ? $temp->{ 'last_param' } : $temp->{ 'last_param1' } ? $temp->{ 'last_param1' } : $temp->{ 'last_param2' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 'context' => $temp->{ 'context' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 'intl_code' => $temp->{ 'intl_code' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | '_intl_code_from_context' => $temp->{ '_intl_code_from_context' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 290 | ▶ | 'local_number' => $temp->{ 'local_number' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition100%3/3
$temp->{"type"} eq "local" or $temp->{"type"} eq "other"
MC/DC100%2/2
$temp->{"type"} eq "local" or $temp->{"type"} eq "other"
$temp->{"type"} eq "local"
$temp->{"type"} eq "other"
Truth table100%3/3
A or B
A= $temp->{"type"} eq "local"B= $temp->{"type"} eq "other"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 290 | my $self = bless( $hash, $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 290 | my $prams = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 290 | ▶ | if( length( $temp->{ 'params' } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 10 | my $pram_str = $temp->{ 'params' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 10 | $pram_str =~ s/^[\.\,\#\;]//; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 10 | $prams = [ $self->split_str( $pram_str ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | ## Private parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 290 | my $priv = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 290 | foreach my $this ( @$prams ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 16 | $this =~ s/^(x|ext)\.?(\d+)$/ext=$2/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 16 | my( $p, $v ) = split( /=/, $this, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 16 | $p =~ s/\-/\_/gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 16 | ▶ | if( lc( $p ) =~ /^(ext|isdn_subaddress)$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 10 | $hash->{ lc( $p ) } = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | elsif( lc( $p ) eq 'phone_context' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | $hash->{ 'context' } = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | $temp->{ '_has_context_param' } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | $priv->{ lc( $p ) } = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 290 | $self->{ 'private' } = $priv; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 290 | ▶ | $self->{ 'ext' } = $temp->{ 'ext' } if( !length( $hash->{ 'ext' } ) && !$self->{ 'is_vanity' } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $hash->{"ext"} or $self->{"is_vanity"}
MC/DC100%2/2
length $hash->{"ext"} or $self->{"is_vanity"}
length $hash->{"ext"}
$self->{"is_vanity"}
Truth table100%3/3
A or B
A= length $hash->{"ext"}B= $self->{"is_vanity"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 290 | $self->{ 'ext' } =~ s/\D//gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ## Because a context may be +81 or it could be a domain name example.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ## if we had it as a parameter at instantiation, we remember it and honour it when we stringify | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 290 | ▶ | $self->{ '_prepend_context' } = $temp->{ '_has_context_param' } ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 290 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 49 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=16 SCAR=28.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 49 | ▶ | return( $self->{ 'cache' } ) if( length( $self->{ 'cache' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 47 | ▶ | my @uri = ( 'tel:' . $self->{ 'subscriber' } ) if( length( $self->{ 'subscriber' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 47 | my @params = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 47 | ▶ | push( @params, sprintf( "ext=%s", $self->{ 'ext' } ) ) if( length( $self->{ 'ext' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 47 | ▶ | push( @params, sprintf( "isub=%s", $self->{ 'isdn_subaddress' } ) ) if( length( $self->{ 'isdn_subaddress' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 47 | ▶ | if( length( $self->{ 'context' } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 31 | ▶ | if( !$self->{ '_prepend_context' } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 15 | push( @params, sprintf( "phone-context=%s", $self->{ 'context' } ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ## Context is not some domain name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ▶ | elsif( $self->{ 'subscriber' } !~ /^\+\d+/ && $self->{ 'context' } !~ /[a-zA-Z]+/ ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'subscriber'} =~ /^\+\d+/ || $self->{'context'} =~ /[a-zA-Z]+/
MC/DC50%1/2
$self->{'subscriber'} =~ /^\+\d+/ || $self->{'context'} =~ /[a-zA-Z]+/
$self->{'subscriber'} =~ /^\+\d+/
$self->{'context'} =~ /[a-zA-Z]+/
Truth table66%2/3
A || B
A= $self->{'subscriber'} =~ /^\+\d+/B= $self->{'context'} =~ /[a-zA-Z]+/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | @uri = ( 'tel:' . $self->{ 'context' } . '-' . $self->{ 'subscriber' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 47 | ▶ | if( length( $self->{ 'intl_code' } ) && !$self->{ '_intl_code_from_context' } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $self->{"intl_code"} and not $self->{"_intl_code_from_context"}
MC/DC100%2/2
length $self->{"intl_code"} and not $self->{"_intl_code_from_context"}
length $self->{"intl_code"}
not $self->{"_intl_code_from_context"}
Truth table100%3/3
A and not(B)
A= length $self->{"intl_code"}B= not $self->{"_intl_code_from_context"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 19 | ▶ | if( $self->{ 'subscriber' } !~ /^\+\d+/ && $uri[0] !~ /^tel\:\+/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"subscriber"} =~ /^\+\d+/ or $uri[0] =~ /^tel\:\+/
MC/DC0%0/2
$self->{"subscriber"} =~ /^\+\d+/ or $uri[0] =~ /^tel\:\+/
$self->{"subscriber"} =~ /^\+\d+/
$uri[0] =~ /^tel\:\+/
Truth table33%1/3
A or B
A= $self->{"subscriber"} =~ /^\+\d+/B= $uri[0] =~ /^tel\:\+/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | @uri = ( 'tel:' . '+' . $self->{ 'intl_code' } . '-' . $self->{ 'subscriber' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 47 | my $priv = $self->{ 'private' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 47 | foreach my $k ( sort( keys( %$priv ) ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 8 | ▶ | push( @params, sprintf( "$k=%s", $priv->{ $k } ) ) if( length( $priv->{ $k } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 47 | ▶ | push( @uri, join( ';', @params ) ) if( scalar( @params ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 47 | $self->{ 'cache' } = join( ';', @uri ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 47 | return( $self->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | *letters2digits = \&aton; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | sub aton | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 21 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
aton: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 21 | ▶ | my $str = shift( @_ ) || $self->{ 'subscriber' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
shift @_ || $self->{'subscriber'}
MC/DC50%1/2
shift @_ || $self->{'subscriber'}
shift @_
$self->{'subscriber'}
Truth table66%2/3
A || B
A= shift @_B= $self->{'subscriber'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 21 | my $letters = 'abcdefghijklmnopqrstuvwxyz'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 21 | my $digits = '22233344455566677778889999'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 21 | ▶ | return( $str ) if( $str !~ /[a-zA-Z]+/ || !$self->is_vanity ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$str =~ /[a-zA-Z]+/ and $self->is_vanity
MC/DC50%1/2
$str =~ /[a-zA-Z]+/ and $self->is_vanity
$str =~ /[a-zA-Z]+/
$self->is_vanity
Truth table66%2/3
A and B
A= $str =~ /[a-zA-Z]+/B= $self->is_vanity
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | $str = lc( $str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 2 | my $res = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 2 | ▶ | for( my $i = 0; $i < length( $str ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 26 | my $c = substr( $str, $i, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 26 | my $p = index( $letters, $c ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 26 | ▶ | $res .= $p != -1 ? substr( $digits, $p, 1 ) : $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | return( $res ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub canonical | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 21 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonical: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 21 | my $tel = $self->aton; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 21 | $tel =~ s/[\Q$VISUAL_SEPARATOR\E]+//gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 21 | my $uri = $self->new( "tel:$tel" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 21 | ▶ | $uri->ext( $self->{ 'ext' } ) if( length( $self->{ 'ext' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 21 | ▶ | $uri->isub( $self->{ 'isdn_subaddress' } ) if( length( $self->{ 'isdn_subaddress' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 21 | ▶ | $uri->context( $self->{ 'context' } ) if( length( $self->{ 'context' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 21 | ▶ | $uri->international_code( $self->{ 'intl_code' } ) if( length( $self->{ 'intl_code' } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 21 | $uri->{ '_has_context_param' } = $self->{ '_has_context_param' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 21 | $uri->{ '_prepend_context' } = $self->{ '_prepend_context' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 21 | $uri->{ '_intl_code_from_context' } = $self->{ '_intl_code_from_context' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 21 | $uri->{ 'local_number' } = $self->{ 'local_number' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 21 | my $priv = $self->{ 'private' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 21 | %{$uri->{ 'private' }} = %$priv; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 21 | return( $uri ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | sub cc2context | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cc2context: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | my $cc = uc( shift( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | ▶ | return( $self->error( "No country code provided." ) ) if( !length( $cc ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 1 | $self->_load_countries; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | my $hash = $COUNTRIES; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | foreach my $k ( sort( keys( %$hash ) ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ## array ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 205 | my $ref = $hash->{ $k }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 205 | foreach my $this ( @$ref ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 217 | ▶ | if( $this->{ 'cc' } eq $cc ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | return( '+' . $k ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ## Nothing found | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | return( '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub clone | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $class = ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my @keys = keys( %$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | @$hash{ @keys } = @$self{ @keys }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | delete( $hash->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | return( bless( $hash, $class ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | sub context | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 280 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 280 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 14 | my $str = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 14 | ▶ | if( $str !~ /^$DESCRIPTOR$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | warn( "'$str' is not a valid context\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | return( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 14 | delete( $self->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 14 | $self->{ '_has_context_param' } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 14 | $self->{ '_prepend_context' } = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 14 | $self->{ 'context' } = $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ## We found an international country code in the prefix provided, so let's set it | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 14 | ▶ | if( !length( $self->{ 'intl_code' } ) && ( my $code = $self->_extract_intl_code( $str ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not length $self->{"intl_code"} and my $code = $self->_extract_intl_code($str)
MC/DC100%2/2
not length $self->{"intl_code"} and my $code = $self->_extract_intl_code($str)
not length $self->{"intl_code"}
my $code = $self->_extract_intl_code($str)
Truth table100%3/3
not(A) and B
A= not length $self->{"intl_code"}B= my $code = $self->_extract_intl_code($str)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 3 | $self->{ '_intl_code_from_context' } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 3 | $self->{ 'intl_code' } = $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 280 | return( $self->{ 'context' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | sub country | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 266 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
country: called CC=7 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 3 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 266 | $self->_load_countries; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 266 | my $hash = $COUNTRIES; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 266 | my $code = $self->international_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 266 | ▶ | return( wantarray() ? () : [] ) if( !length( $code ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 255 | $code =~ s/[\Q$VISUAL_SEPARATOR\E]+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 255 | ▶ | if( $code =~ /^\+($IDD_RE)/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $code = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 255 | ▶ | return( wantarray() ? () : [] ) if( !exists( $hash->{ $code } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 255 | my $ref = $hash->{ $code }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 255 | ▶ | return( wantarray() ? @$ref : \@$ref ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | sub country_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 245 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
country_code: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 245 | my $ref = $self->country_codes; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 245 | ▶ | return( '' ) if( ref( $ref ) ne 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 245 | return( $ref->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | sub country_codes | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 245 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
country_codes: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 245 | my $ref = $self->country; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 245 | ▶ | return( '' ) if( ref( $ref ) ne 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 245 | my @codes = map( $_->{cc}, @$ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 245 | ▶ | return( wantarray() ? @codes : \@codes ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | sub country_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
country_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $ref = $self->country_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | return( '' ) if( ref( $ref ) ne 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | return( $ref->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | sub country_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
country_names: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $ref = $self->country; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | return( '' ) if( ref( $ref ) ne 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my @names = map( $_->{name}, @$ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | return( wantarray() ? @names : \@names ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | sub error | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my $level = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $err = join( '', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if( $err && length( $err ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$err and length $err
MC/DC0%0/2
$err and length $err
$err
length $err
Truth table0%0/3
A and B
A= $errB= length $err
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my( $frame, $caller ) = ( $level, '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | while( $caller = ( caller( $frame ) )[ 0 ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | last if( $caller ne 'URI::tel' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $frame++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my( $pack, $file, $line ) = caller( $frame ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $err =~ s/\n$//gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | $self->{ 'error' } = ${ $class . '::ERROR' } = $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | return( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | return( $self->{ 'error' } || $ERROR ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'error'} || $ERROR
MC/DC0%0/2
$self->{'error'} || $ERROR
$self->{'error'}
$ERROR
Truth table0%0/3
A || B
A= $self->{'error'}B= $ERROR
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 3 | *extension = \&ext; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | sub ext | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 33 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ext: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 33 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 11 | my $val = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 11 | ▶ | if( length( $val ) && $val !~ /^[$PHONEDIGIT]+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $val and not $val =~ /^[$PHONEDIGIT]+$/
MC/DC0%0/2
length $val and not $val =~ /^[$PHONEDIGIT]+$/
length $val
not $val =~ /^[$PHONEDIGIT]+$/
Truth table33%1/3
A and not(B)
A= length $valB= not $val =~ /^[$PHONEDIGIT]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | warn( "'$val' is not a valid extension ([$PHONEDIGIT]+)\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | return( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 11 | delete( $self->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 11 | $self->{ 'ext' } = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 33 | return( $self->{ 'ext' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | sub international_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 276 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
international_code: called CC=4 SCAR=14.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 276 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 10 | my $val = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 10 | ▶ | if( length( $val ) && $val !~ /^[$PHONEDIGIT]+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $val and not $val =~ /^[$PHONEDIGIT]+$/
MC/DC0%0/2
length $val and not $val =~ /^[$PHONEDIGIT]+$/
length $val
not $val =~ /^[$PHONEDIGIT]+$/
Truth table33%1/3
A and not(B)
A= length $valB= not $val =~ /^[$PHONEDIGIT]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | warn( "'$val' is not a valid international code.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | return( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 10 | delete( $self->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | ## The international code was provided by the user as opposed to using the context() method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | ## so we flag it properly so it can be used in stringification of the phone number | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 10 | $self->{ '_intl_code_from_context' } = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 10 | $self->{ 'is_global' } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 10 | $self->{ 'intl_code' } = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 276 | return( $self->{ 'intl_code' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | sub is_global | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 21 | ▶ | return( shift->{ 'is_global' } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_global: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | sub is_local | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | return( shift->{ 'is_local' } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_local: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | sub is_other | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | return( shift->{ 'is_other' } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_other: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | sub is_vanity | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | ▶ | return( shift->{ 'is_vanity' } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_vanity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | *isdn_subaddress = \&isub; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | sub isub | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 21 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isub: called CC=4 SCAR=23.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 21 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $val = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | if( length( $val ) && $val !~ /^$URIC$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $val and not $val =~ /^$URIC$/
MC/DC0%0/2
length $val and not $val =~ /^$URIC$/
length $val
not $val =~ /^$URIC$/
Truth table0%0/3
A and not(B)
A= length $valB= not $val =~ /^$URIC$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | warn( "'$val' is not a isdn subaddress\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | return( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | delete( $self->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | $self->{ 'isub' } = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 21 | return( $self->{ 'isub' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | sub original | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | return( shift->{ 'original' } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
original: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | sub prepend_context | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepend_context: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 1 | $self->{ '_prepend_context' } = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 1 | delete( $self->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1 | return( $self->{ '_prepend_context' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | sub private | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 3 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
private: called CC=8 SCAR=37.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 3 | my( $name, $val ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 3 | ▶ | if( length( $name ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | ## The value could be blank and if so, we would remove the parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if( defined( $val ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | if( $name !~ /^$PNAME$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | warn( "'$name' is not a valid parameter name.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | return( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | if( length( $val ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if( $val !~ /^$PVALUE$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | warn( "'$val' is not a valid parameter value.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | return( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | delete( $self->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $self->{ 'private' }->{ $name } = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | return( $self->{ 'private' }->{ $name } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | return( delete( $self->{ 'private' }->{ $name } ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | return( wantarray() ? %${$self->{ 'private' }->{ $name }} : \%${$self->{ 'private' }->{ $name }} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 3 | ▶ | return( wantarray() ? %{$self->{ 'private' }} : \%{$self->{ 'private' }} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | sub subscriber | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 21 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subscriber: called CC=4 SCAR=23.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 21 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $val = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | if( length( $val ) && $val !~ /^$TEL_SUBSCRIBER$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $val and not $val =~ /^$TEL_SUBSCRIBER$/
MC/DC0%0/2
length $val and not $val =~ /^$TEL_SUBSCRIBER$/
length $val
not $val =~ /^$TEL_SUBSCRIBER$/
Truth table0%0/3
A and not(B)
A= length $valB= not $val =~ /^$TEL_SUBSCRIBER$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | warn( "'$val' is not a valid subscriber value.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | return( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | delete( $self->{ 'cache' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $self->{ 'subscriber' } = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 21 | return( $self->{ 'subscriber' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | sub type | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | return( shift->{ 'type' } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | sub _extract_intl_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 271 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_intl_code: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 271 | ▶ | my $str = shift( @_ ) || return( '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return '')
MC/DC0%0/1
shift @_ || (return '')
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | #print( STDERR "Trying to find international code from '$str'\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 271 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ## Extract the global idd | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 271 | $self->_load_countries; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 271 | ( my $str2 = $str ) =~ s/[\Q$VISUAL_SEPARATOR\E]+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 271 | $str2 =~ s/^tel\://; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 271 | ▶ | if( $str2 =~ /^\+($IDD_RE)/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 268 | my $idd = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | #print( STDERR "\tIDD is '$idd'\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 268 | ▶ | if( CORE::exists( $COUNTRIES->{ $idd } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 268 | my $idds = $COUNTRIES->{ $idd }->[0]->{ 'idd' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | #print( STDERR "\tFound entry.\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 268 | foreach my $thisIdd ( @$idds ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 277 | my $check = $thisIdd; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 277 | $check =~ s/\D//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 277 | ▶ | if( $check eq $idd ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | #$temp->{ 'context' } = '+' . $thisIdd; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 268 | $code = $thisIdd; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 268 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | #print( STDERR "\tReturning '$code'\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 271 | return( $code ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | sub _extract_local_number | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 262 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_local_number: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 262 | my( $intl_code, $subscriber ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 262 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 262 | ▶ | for( my $i = 0; $i < length( $intl_code ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # Skip until we are on a number | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 800 | ▶ | next if( substr( $intl_code, $i, 1 ) !~ /^\d$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | # and here too so we can compare number to number | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 758 | ▶ | while( substr( $subscriber, $j, 1 ) !~ /^\d$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 262 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # Our international code does not seem to match the prefix of our subscriber! This should not happen. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 758 | ▶ | if( substr( $subscriber, $j, 1 ) ne substr( $intl_code, $i, 1 ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # printf( STDERR "Mismatch... %s at position %d vs %s at position %d\n", substr( $intl_code, $i, 1 ), $i, substr( $subscriber, $j, 1 ), $j ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | #last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | return( '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 758 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 262 | ▶ | $j++ while( substr( $subscriber, $j, 1 ) !~ /^\d$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 262 | return( substr( $subscriber, $j ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | # Check if two objects are the same object | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | # https://tools.ietf.org/search/rfc3966#section-4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | sub _obj_eq | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | ##return overload::StrVal( $_[0] ) eq overload::StrVal( $_[1] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 3 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_obj_eq: not called CC=12 SCAR=48.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $other = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | return( 0 ) if( !ref( $other ) || !$other->isa( 'URI::tel' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $other and $other->isa("URI::tel")
MC/DC0%0/2
ref $other and $other->isa("URI::tel")
ref $other
$other->isa("URI::tel")
Truth table0%0/3
A and B
A= ref $otherB= $other->isa("URI::tel")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my $sub = $self->canonical->subscriber; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $sub2 = $other->canonical->subscriber; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | $sub =~ s/^\+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $sub2 =~ s/^\+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | return( 0 ) if( $sub ne $sub2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my $context = $self->context; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | my $context2 = $other->context; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | return( 0 ) if( $context ne $context2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my $ext = $self->ext; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | my $ext2 = $other->ext; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | return( 0 ) if( $ext ne $ext2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $priv = $self->private; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $priv2 = $other->private; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | foreach my $k ( keys( %$priv ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | return( 0 ) if( !exists( $priv2->{ $k } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | return( 0 ) if( $priv->{ $k } ne $priv2->{ $k } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | foreach my $k ( keys( %$priv2 ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | return( 0 ) if( !exists( $priv->{ $k } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | return( 0 ) if( $priv2->{ $k } ne $priv->{ $k } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 3 | ▶ | use overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | return( 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | ## Taken from http://www.perlmonks.org/bare/?node_id=319761 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | ## This will do a split on a semi-colon, but being mindful if before it there is an escaped backslash | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ## For example, this would not be skipped: something\;here | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | ## But this would be split: something\\;here resulting in something\ and here after unescaping | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | sub split_str | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 10 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_str: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 10 | my $s = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 10 | ▶ | my $sep = @_ ? shift( @_ ) : ';'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 10 | my @parts = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 10 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 10 | foreach( split( /(\\.)|$sep/, $s ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 22 | ▶ | defined( $_ ) ? do{ $parts[$i] .= $_ } : do{ $i++ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 10 | return( @parts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | sub _load_countries | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 539 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_countries: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 539 | ▶ | if( !%$COUNTRIES ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 2 | my $in = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 2 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 2 | my @data = <DATA>; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 2 | foreach ( @data ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 960 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 960 | ▶ | next unless( $in || /^\#{2} BEGIN DATA/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$in or /^\#{2} BEGIN DATA/
MC/DC100%2/2
$in or /^\#{2} BEGIN DATA/
$in
/^\#{2} BEGIN DATA/
Truth table100%3/3
A or B
A= $inB= /^\#{2} BEGIN DATA/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 504 | ▶ | last if( /^\#{2} END DATA/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 502 | $in++; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 502 | ▶ | next if( /^\#{2} BEGIN DATA/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 500 | my( $cc, $cc3, $name, $idd ) = split( /[[:blank:]]*\;[[:blank:]]*/, $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 500 | ▶ | my $keys = index( $idd, ',' ) != -1 ? [ split( /[[:blank:]]*\,[[:blank:]]*/, $idd ) ] : [ $idd ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 500 | my $info = | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 'cc' => $cc, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 'cc3' => $cc3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 'name' => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 'idd' => $idd, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 500 | $info->{ 'idd' } = $keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 500 | foreach my $k ( @$keys ) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 514 | my $k2 = $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 514 | $k2 =~ s/-//gs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 514 | ▶ | $hash->{ $k2 } = [] if( !exists( $hash->{ $k2 } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 514 | push( @{$hash->{ $k2 }}, $info ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 2 | $COUNTRIES = $hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 2 | my @list = sort{ $b <=> $a } keys( %$hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 2 | my $re_list = join( '|', @list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 2 | $IDD_RE = qr{(?:$re_list)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||