lib/PersonName/Format/FieldModifier.pm

filter: Statementstmt 81.7% 157 / 192 Branchbran 64.7% 57 / 88 Conditioncond 43.9% 29 / 66 MC/DCmcdc 10.0% 4 / 40 Subroutinesub 79.3% 23 / 29 Podpod 100% 7 / 7 totaltotal 65.6% 277 / 422 CC 72 SCAR 28.9
CC
72
Cov
70%
init
50.3
__ANON__
20.0
resolve
16.0
CRAP 17.9
« lib/PersonName/Format/SimpleName.pm ↑ Summary lib/PersonName/Format/Pattern.pm »
1 ##----------------------------------------------------------------------------
2 ## Person Name Format - ~/lib/PersonName/Format/FieldModifier.pm
3 ## Version v0.1.0
4 ## Copyright(c) 2026 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2026/07/16
7 ## Modified 2026/07/16
8 ## All rights reserved
9 ##
10 ## This program is free software; you can redistribute it and/or modify it
11 ## under the same terms as Perl itself.
12 ##----------------------------------------------------------------------------
13 package PersonName::Format::FieldModifier;
14 BEGIN
15 20 ▶{
Subroutine BEGIN: called CC=3 SCAR=13.2
16 20 ▶ use v5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 20 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 20 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 20 ▶ if( $] < 5.013 )
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.013") 0 20 20
20 {
21 20 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 0 ▶ unless( defined( &warnings::register_categories ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &warnings::register_categories) 0 0 0
23 {
24 *warnings::_mkMask = sub
25 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 my $bit = shift( @_ );
27 0 my $mask = "";
28 0 vec( $mask, $bit, 1 ) = 1;
29 0 return( $mask );
30 0 };
31  
32 *warnings::register_categories = sub
33 0 ▶ {
Subroutine __ANON__: not called CC=4 SCAR=30.0
34 0 my @names = @_;
35 0 foreach my $name ( @names )
36 {
37 0 ▶ if( !defined( $warnings::Bits{ $name } ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $warnings::Bits{$name}) 0 0 0
38 {
39 0 $warnings::Offsets{ $name } = $warnings::LAST_BIT;
40 0 $warnings::Bits{ $name } = warnings::_mkMask( $warnings::LAST_BIT++ );
41 0 $warnings::DeadBits{ $name } = warnings::_mkMask( $warnings::LAST_BIT++ );
42 0 ▶ if( length( $warnings::Bits{ $name } ) > length( $warnings::Bits{all} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (length $warnings::Bits{$name} > length $warnings::Bits{"all"}) 0 0 0
43 {
44 0 $warnings::Bits{all} .= "\x55";
45 0 $warnings::DeadBits{all} .= "\xaa";
46 }
47 }
48 }
49 0 };
50 }
51 }
52 20 warnings::register_categories( 'PersonName::Format' );
53 20 ▶ use parent qw( PersonName::Format::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
54 20 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
55 20 ▶ use Locale::Unicode;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 20 ▶ use PersonName::Format::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
57 20 ▶ use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
58 20 our( $VERSION ) = 'v0.1.0';
59 };
60  
61 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
63  
64 sub init
65 23 ▶{
Subroutine init: called CC=21 SCAR=39.2
Pod documented
66 23 my $self = shift( @_ );
67 23 my $locale = shift( @_ );
68 23 ▶ if( !defined( $locale ) || !length( "$locale" ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $locale and length "$locale") 0 23 23
Condition33%1/3
defined $locale and length "$locale"
!ll&&!rl&&r
0023
MC/DC0%0/2
defined $locale and length "$locale"
defined $locale length "$locale"
Truth table33%1/3
A and B
A= defined $localeB= length "$locale"
ABresult
0X0
100
111
69 {
70 0 return( $self->error( "No modifier locale was provided." ) );
71 }
72 23 my $args = $self->_get_args_as_hash( @_ );
73 # $self->{_init_strict_use_sub} = 1;
74 $self->SUPER::init(
75 debug => delete( $args->{debug} ),
76 23 ▶ fatal => delete( $args->{fatal} ),
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init("debug", delete $args->{"debug"}, "fatal", delete $args->{"fatal"}) or return $self->pass_error 23 0 23
77 ) || return( $self->pass_error );
78 23 ▶ my $locale_object = Locale::Unicode->new( $locale ) ||
Condition50%1/2
'Locale::Unicode'->new($locale) || (return $self->pass_error('Locale::Unicode'->error))
l!l
230
MC/DC0%0/1
'Locale::Unicode'->new($locale) || (return $self->pass_error('Locale::Unicode'->error))
'Locale::Unicode'->new($locale)
Truth table50%1/2
A
A= 'Locale::Unicode'->new($locale)
Aresult
11
00
79 return( $self->pass_error( Locale::Unicode->error ) );
80 23 $self->{locale} = $locale_object;
81  
82 23 my $data = delete( $args->{data} );
83 23 my $initial_pattern = delete( $args->{initial_pattern} );
84 23 my $initial_sequence_pattern = delete( $args->{initial_sequence_pattern} );
85  
86 23 ▶ if( defined( $data ) )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $data) { } 21 2 23
elsif (not defined $initial_pattern && defined $initial_sequence_pattern) { } 0 2 2
87 {
88 21 ▶ unless( Scalar::Util::blessed( $data ) &&
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($data) and $self->_can($data, ["make_inheritance_tree", "person_name_initial_pattern"])) 0 21 21
Condition33%1/3
builtin::blessed($data) and $self->_can($data, ["make_inheritance_tree", "person_name_initial_pattern"])
!ll&&!rl&&r
0021
MC/DC0%0/2
builtin::blessed($data) and $self->_can($data, ["make_inheritance_tree", "person_name_initial_pattern"])
builtin::blessed($data) $self->_can($data, ["make_inheritance_tree", "person_name_initial_pattern"])
Truth table33%1/3
A and B
A= builtin::blessed($data)B= $self->_can($data, ["make_inheritance_tree", "person_name_initial_pattern"])
ABresult
0X0
100
111
89 $self->_can( $data, [qw( make_inheritance_tree person_name_initial_pattern )] ) )
90 {
91 0 return( $self->error( "The data option must provide the Locale::Unicode::Data initial-pattern contract." ) );
92 }
93 }
94 ▶ elsif( !defined( $initial_pattern ) ||
Condition33%1/3
defined $initial_pattern && defined $initial_sequence_pattern
!ll&&!rl&&r
002
MC/DC0%0/2
defined $initial_pattern && defined $initial_sequence_pattern
defined $initial_pattern defined $initial_sequence_pattern
Truth table33%1/3
A && B
A= defined $initial_patternB= defined $initial_sequence_pattern
ABresult
0X0
100
111
95 !defined( $initial_sequence_pattern ) )
96 {
97 0 local $@;
98 0 eval{ require Locale::Unicode::Data; };
99 0 ▶ return( $self->error( "Unable to load Locale::Unicode::Data: ", ( $@ || 'unknown error' ) ) ) if( $@ );
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
Condition0%0/2
$@ || 'unknown error'
l!l
00
MC/DC0%0/1
$@ || 'unknown error'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
100 0 ▶ $data = Locale::Unicode::Data->new ||
Condition0%0/2
'Locale::Unicode::Data'->new || (return $self->pass_error('Locale::Unicode::Data'->error))
l!l
00
MC/DC0%0/1
'Locale::Unicode::Data'->new || (return $self->pass_error('Locale::Unicode::Data'->error))
'Locale::Unicode::Data'->new
Truth table0%0/2
A
A= 'Locale::Unicode::Data'->new
Aresult
11
00
101 return( $self->pass_error( Locale::Unicode::Data->error ) );
102 }
103 23 $self->{data} = $data;
104 23 ▶ if( scalar( keys( %$args ) ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %$args) 0 23 23
105 {
106 0 return( $self->error( "Unknown FieldModifier option '", ( keys( %$args ) )[0], "'." ) );
107 }
108  
109 23 ▶ if( !defined( $initial_pattern ) ||
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $initial_pattern and defined $initial_sequence_pattern) 21 2 23
Condition66%2/3
defined $initial_pattern and defined $initial_sequence_pattern
!ll&&!rl&&r
2102
MC/DC50%1/2
defined $initial_pattern and defined $initial_sequence_pattern
defined $initial_pattern defined $initial_sequence_pattern
Truth table66%2/3
A and B
A= defined $initial_patternB= defined $initial_sequence_pattern
ABresult
0X0
100
111
110 !defined( $initial_sequence_pattern ) )
111 {
112 21 ▶ my $patterns = $self->_load_initial_patterns ||
Condition50%1/2
$self->_load_initial_patterns || (return $self->pass_error)
l!l
210
MC/DC0%0/1
$self->_load_initial_patterns || (return $self->pass_error)
$self->_load_initial_patterns
Truth table50%1/2
A
A= $self->_load_initial_patterns
Aresult
11
00
113 return( $self->pass_error );
114 21 ▶ if( !defined( $initial_pattern ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $initial_pattern) 21 0 21
115 {
116 21 $initial_pattern = $patterns->{initial};
117 }
118 21 ▶ if( !defined( $initial_sequence_pattern ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $initial_sequence_pattern) 21 0 21
119 {
120 21 $initial_sequence_pattern = $patterns->{initialSequence};
121 }
122 }
123  
124 23 ▶ unless( $self->_valid_initial_pattern( $initial_pattern ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_valid_initial_pattern($initial_pattern)) 1 22 23
125 {
126 1 return( $self->error( "The initial pattern must contain exactly one '{0}' placeholder." ) );
127 }
128 22 ▶ unless( $self->_valid_initial_sequence_pattern( $initial_sequence_pattern ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_valid_initial_sequence_pattern($initial_sequence_pattern)) 0 22 22
129 {
130 0 return( $self->error( "The initial sequence pattern must contain exactly one '{0}' and one '{1}' placeholder." ) );
131 }
132 22 $self->{initial_pattern} = "$initial_pattern";
133 22 $self->{initial_sequence_pattern} = "$initial_sequence_pattern";
134 22 return( $self );
135 }
136  
137 sub data
138 0 ▶{
Subroutine data: not called CC=1 SCAR=6.9
Pod documented
139 0 return( shift->{data} );
140 }
141  
142 sub initial_pattern
143 2 ▶{
Subroutine initial_pattern: called CC=1 SCAR=0.0
Pod documented
144 2 return( shift->_set_get_scalar( 'initial_pattern', @_ ) );
145 }
146  
147 sub initial_sequence_pattern
148 2 ▶{
Subroutine initial_sequence_pattern: called CC=1 SCAR=0.0
Pod documented
149 2 return( shift->_set_get_scalar( 'initial_sequence_pattern', @_ ) );
150 }
151  
152 sub locale
153 0 ▶{
Subroutine locale: not called CC=1 SCAR=6.9
Pod documented
154 0 return( shift->{locale} );
155 }
156  
157 sub resolve
158 31 ▶{
Subroutine resolve: called CC=14 SCAR=27.7
Pod documented
159 31 my $self = shift( @_ );
160 31 my $modifier = shift( @_ );
161 31 my $value = shift( @_ );
162 31 my $field = shift( @_ );
163 31 my $token = shift( @_ );
164 31 my $name = shift( @_ );
165 31 ▶ if( !defined( $modifier ) || !length( $modifier ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $modifier and length $modifier) 0 31 31
Condition33%1/3
defined $modifier and length $modifier
!ll&&!rl&&r
0031
MC/DC0%0/2
defined $modifier and length $modifier
defined $modifier length $modifier
Truth table33%1/3
A and B
A= defined $modifierB= length $modifier
ABresult
0X0
100
111
166 {
167 0 return( $self->error( "No field modifier was provided to resolve()." ) );
168 }
169 31 ▶ return if( !defined( $value ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 31 31
170  
171 31 ▶ if( $modifier eq 'allCaps' )
Branch: 5 branches
BranchTrueFalseTotal
if ($modifier eq 'allCaps') { } 6 25 31
elsif ($modifier eq 'initialCap') { } 1 24 25
elsif ($modifier eq 'initial') { } 16 8 24
elsif ($modifier eq 'monogram') { } 4 4 8
elsif ($modifier eq 'retain' or $modifier eq 'genitive' or $modifier eq 'vocative') { } 4 0 4
172 {
173 6 return( uc( $value ) );
174 }
175 elsif( $modifier eq 'initialCap' )
176 {
177 1 return( $self->_initial_cap( $value ) );
178 }
179 elsif( $modifier eq 'initial' )
180 {
181 16 my $retain = 0;
182 16 ▶ if( ref( $token ) eq 'HASH' &&
Branch: 1 branch
BranchTrueFalseTotal
if (ref $token eq "HASH" and ref $token->{"modifiers"} eq "ARRAY") 16 0 16
Condition33%1/3
ref $token eq "HASH" and ref $token->{"modifiers"} eq "ARRAY"
!ll&&!rl&&r
0016
MC/DC0%0/2
ref $token eq "HASH" and ref $token->{"modifiers"} eq "ARRAY"
ref $token eq "HASH" ref $token->{"modifiers"} eq "ARRAY"
Truth table33%1/3
A and B
A= ref $token eq "HASH"B= ref $token->{"modifiers"} eq "ARRAY"
ABresult
0X0
100
111
183 ref( $token->{modifiers} ) eq 'ARRAY' )
184 {
185 16 ▶ $retain = scalar( grep{ $_ eq 'retain' } @{$token->{modifiers}} ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
scalar grep({$_ eq 'retain';} @{$$token{'modifiers'};}) ? : 2 14 16
186 }
187 16 return( $self->_initial( $value, $retain ) );
188 }
189 elsif( $modifier eq 'monogram' )
190 {
191 4 return( $self->_first_grapheme( $value ) );
192 }
193 ▶ elsif( $modifier eq 'retain' ||
Condition83%5/6
$modifier eq "retain" or $modifier eq "genitive" or $modifier eq "vocative"
l!l&&r!l&&!r
310
$modifier eq "retain" or $modifier eq "genitive"
l!l&&r!l&&!r
211
MC/DC0%0/3
$modifier eq "retain" or $modifier eq "genitive" or $modifier eq "vocative"
$modifier eq "retain" $modifier eq "genitive" $modifier eq "vocative"
Truth table75%3/4
A or B or C
A= $modifier eq "retain"B= $modifier eq "genitive"C= $modifier eq "vocative"
ABCresult
1XX1
01X1
0011
0000
194 $modifier eq 'genitive' ||
195 $modifier eq 'vocative' )
196 {
197 4 return( $value );
198 }
199 0 return( $self->error( "Unsupported person-name field modifier '${modifier}'." ) );
200 }
201  
202 sub resolver
203 0 ▶{
Subroutine resolver: not called CC=1 SCAR=6.9
Pod documented
204 0 my $self = shift( @_ );
205 return( sub
206 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
207 0 return( $self->resolve( @_ ) );
208 0 });
209 }
210  
211 sub _first_grapheme
212 5 ▶{
Subroutine _first_grapheme: called CC=2 SCAR=7.4
213 5 my $self = shift( @_ );
214 5 my $value = shift( @_ );
215 5 ▶ if( defined( &PersonName::Format::_first_grapheme ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined &PersonName::Format::_first_grapheme) 0 5 5
216 {
217 0 return( PersonName::Format::_first_grapheme( $value ) );
218 }
219 5 return( PersonName::Format::PP::_first_grapheme( $value ) );
220 }
221  
222 sub _format_pattern
223 28 ▶{
Subroutine _format_pattern: called CC=1 SCAR=0.0
224 28 my $self = shift( @_ );
225 28 my $pattern = shift( @_ );
226 28 my $values = shift( @_ );
227 28 my $result = "$pattern";
228 28 $result =~ s/\{([01])\}/$values->[$1]/ge;
229 28 return( $result );
230 }
231  
232 sub _initial
233 16 ▶{
Subroutine _initial: called CC=11 SCAR=24.1
234 16 my $self = shift( @_ );
235 16 my $value = shift( @_ );
236 16 my $retain = shift( @_ );
237 16 ▶ return( '' ) if( !defined( $value ) || !length( $value ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and length $value 0 16 16
Condition33%1/3
defined $value and length $value
!ll&&!rl&&r
0016
MC/DC0%0/2
defined $value and length $value
defined $value length $value
Truth table33%1/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
238 16 my $initials = [];
239 16 my $separators = [];
240 16 my $separator = '';
241 16 my $in_word = 0;
242  
243 16 ▶ while( $value =~ /(\X)/gs )
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /(\X)/gs) 110 16 126
244 {
245 110 my $grapheme = $1;
246 110 ▶ if( $grapheme =~ /\p{L}/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($grapheme =~ /\p{L}/) { } 101 9 110
247 {
248 101 ▶ if( !$in_word )
Branch: 1 branch
BranchTrueFalseTotal
unless ($in_word) 23 78 101
249 {
250 23 ▶ push( @$separators, $separator ) if( @$initials );
Branch: 1 branch
BranchTrueFalseTotal
if @$initials 7 16 23
251 23 push( @$initials, $grapheme );
252 23 $separator = '';
253 }
254 101 $in_word = 1;
255 }
256 else
257 {
258 9 $in_word = 0;
259 9 $separator .= $grapheme;
260 }
261 }
262 16 ▶ return( '' ) unless( @$initials );
Branch: 1 branch
BranchTrueFalseTotal
unless @$initials 0 16 16
263  
264 my $result = $self->_format_pattern(
265 $self->{initial_pattern},
266 16 [$initials->[0]],
267 );
268 16 ▶ for( my $i = 1; $i < scalar( @$initials ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$initials) 7 16 23
269 {
270 my $current = $self->_format_pattern(
271 $self->{initial_pattern},
272 7 [$initials->[$i]],
273 );
274 7 ▶ if( $retain )
Branch: 1 branch
BranchTrueFalseTotal
if ($retain) { } 2 5 7
275 {
276 2 ▶ my $between = $separators->[$i - 1] // '';
Condition50%1/2
$$separators[$i - 1] // ""
l!l
20
MC/DC0%0/1
$$separators[$i - 1] // ""
$$separators[$i - 1]
Truth table50%1/2
A
A= $$separators[$i - 1]
Aresult
11
00
277 2 $between =~ s/\s+/ /gs;
278 2 $result .= $between . $current;
279 }
280 else
281 {
282 $result = $self->_format_pattern(
283 $self->{initial_sequence_pattern},
284 5 [$result, $current],
285 );
286 }
287 }
288 16 return( $result );
289 }
290  
291 sub _initial_cap
292 1 ▶{
Subroutine _initial_cap: called CC=4 SCAR=15.0
293 1 my $self = shift( @_ );
294 1 my $value = shift( @_ );
295 1 ▶ return( '' ) if( !defined( $value ) || !length( $value ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and length $value 0 1 1
Condition33%1/3
defined $value and length $value
!ll&&!rl&&r
001
MC/DC0%0/2
defined $value and length $value
defined $value length $value
Truth table33%1/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
296 1 my $first = $self->_first_grapheme( $value );
297 1 ▶ return( $value ) unless( length( $first ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length $first 0 1 1
298 1 return( uc( $first ) . substr( $value, length( $first ) ) );
299 }
300  
301 sub _load_initial_patterns
302 21 ▶{
Subroutine _load_initial_patterns: called CC=13 SCAR=27.4
303 21 my $self = shift( @_ );
304 my $tree = $self->{data}->make_inheritance_tree( $self->{locale} ) ||
305 21 ▶ return( $self->pass_error( $self->{data}->error ) );
Condition50%1/2
$self->{'data'}->make_inheritance_tree($self->{'locale'}) || (return $self->pass_error($self->{'data'}->error))
l!l
210
MC/DC0%0/1
$self->{'data'}->make_inheritance_tree($self->{'locale'}) || (return $self->pass_error($self->{'data'}->error))
$self->{'data'}->make_inheritance_tree($self->{'locale'})
Truth table50%1/2
A
A= $self->{'data'}->make_inheritance_tree($self->{'locale'})
Aresult
11
00
306 21 my $patterns = {};
307  
308 21 foreach my $locale ( @$tree )
309 {
310 43 foreach my $type ( qw( initial initialSequence ) )
311 {
312 86 ▶ next if( exists( $patterns->{ $type } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $patterns->{$type} 2 84 86
313 my $ref = $self->{data}->person_name_initial_pattern(
314 84 locale => $locale,
315 pattern_type => $type,
316 );
317 84 ▶ if( !defined( $ref ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ref) 42 42 84
318 {
319 42 ▶ if( $self->{data}->error )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"data"}->error) 0 42 42
320 {
321 0 return( $self->pass_error( $self->{data}->error ) );
322 }
323 42 next;
324 }
325 42 ▶ if( exists( $ref->{pattern_value} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ref->{"pattern_value"} and defined $ref->{"pattern_value"}) 42 0 42
Condition33%1/3
exists $ref->{"pattern_value"} and defined $ref->{"pattern_value"}
!ll&&!rl&&r
0042
MC/DC0%0/2
exists $ref->{"pattern_value"} and defined $ref->{"pattern_value"}
exists $ref->{"pattern_value"} defined $ref->{"pattern_value"}
Truth table33%1/3
A and B
A= exists $ref->{"pattern_value"}B= defined $ref->{"pattern_value"}
ABresult
0X0
100
111
326 defined( $ref->{pattern_value} ) )
327 {
328 42 $patterns->{ $type } = $ref->{pattern_value};
329 }
330 }
331 43 ▶ if( exists( $patterns->{initial} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $patterns->{"initial"} and exists $patterns->{"initialSequence"}) 21 22 43
Condition100%3/3
exists $patterns->{"initial"} and exists $patterns->{"initialSequence"}
!ll&&!rl&&r
20221
MC/DC100%2/2
exists $patterns->{"initial"} and exists $patterns->{"initialSequence"}
exists $patterns->{"initial"} exists $patterns->{"initialSequence"}
Truth table100%3/3
A and B
A= exists $patterns->{"initial"}B= exists $patterns->{"initialSequence"}
ABresult
0X0
100
111
332 exists( $patterns->{initialSequence} ) )
333 {
334 21 last;
335 }
336 }
337  
338 21 ▶ unless( exists( $patterns->{initial} ) &&
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $patterns->{"initial"} and exists $patterns->{"initialSequence"}) 0 21 21
Condition33%1/3
exists $patterns->{"initial"} and exists $patterns->{"initialSequence"}
!ll&&!rl&&r
0021
MC/DC0%0/2
exists $patterns->{"initial"} and exists $patterns->{"initialSequence"}
exists $patterns->{"initial"} exists $patterns->{"initialSequence"}
Truth table33%1/3
A and B
A= exists $patterns->{"initial"}B= exists $patterns->{"initialSequence"}
ABresult
0X0
100
111
339 exists( $patterns->{initialSequence} ) )
340 {
341 0 return( $self->error( "Unable to find both initial and initialSequence patterns for locale '", $self->{locale}, "'." ) );
342 }
343 21 return( $patterns );
344 }
345  
346 sub _valid_initial_pattern
347 23 ▶{
Subroutine _valid_initial_pattern: called CC=4 SCAR=14.8
348 23 my $self = shift( @_ );
349 23 my $pattern = shift( @_ );
350 23 ▶ return(0) if( !defined( $pattern ) || ref( $pattern ) );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $pattern or ref $pattern 0 23 23
Condition33%1/3
not defined $pattern or ref $pattern
l!l&&r!l&&!r
0023
MC/DC0%0/2
not defined $pattern or ref $pattern
not defined $pattern ref $pattern
Truth table33%1/3
not(A) or B
A= not defined $patternB= ref $pattern
ABresult
1X1
011
000
351 23 my @zero = "$pattern" =~ /\{0\}/g;
352 23 my @other = "$pattern" =~ /\{(?!0\})[^}]*\}/g;
353 23 ▶ return( scalar( @zero ) == 1 && !@other );
Condition66%2/3
scalar @zero == 1 && !@other
!ll&&!rl&&r
1022
MC/DC50%1/2
scalar @zero == 1 && !@other
scalar @zero == 1 !@other
Truth table66%2/3
A && not(B)
A= scalar @zero == 1B= !@other
ABresult
0X0
100
111
354 }
355  
356 sub _valid_initial_sequence_pattern
357 22 ▶{
Subroutine _valid_initial_sequence_pattern: called CC=5 SCAR=18.7
358 22 my $self = shift( @_ );
359 22 my $pattern = shift( @_ );
360 22 ▶ return(0) if( !defined( $pattern ) || ref( $pattern ) );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $pattern or ref $pattern 0 22 22
Condition33%1/3
not defined $pattern or ref $pattern
l!l&&r!l&&!r
0022
MC/DC0%0/2
not defined $pattern or ref $pattern
not defined $pattern ref $pattern
Truth table33%1/3
not(A) or B
A= not defined $patternB= ref $pattern
ABresult
1X1
011
000
361 22 my @zero = "$pattern" =~ /\{0\}/g;
362 22 my @one = "$pattern" =~ /\{1\}/g;
363 22 my @other = "$pattern" =~ /\{(?![01]\})[^}]*\}/g;
364 22 ▶ return( scalar( @zero ) == 1 &&
Condition33%2/6
scalar @zero == 1 && scalar @one == 1 && !@other
!ll&&!rl&&r
0022
scalar @zero == 1 and scalar @one == 1
!ll&&!rl&&r
0022
MC/DC0%0/3
scalar @zero == 1 && scalar @one == 1 && !@other
scalar @zero == 1 scalar @one == 1 !@other
Truth table25%1/4
A and B && not(C)
A= scalar @zero == 1B= scalar @one == 1C= !@other
ABCresult
0XX0
10X0
1100
1111
365 scalar( @one ) == 1 &&
366 !@other );
367 }
368  
369 20 1;
370 # NOTE: POD
371 __END__
« lib/PersonName/Format/SimpleName.pm ↑ Summary lib/PersonName/Format/Pattern.pm »