lib/Locale/Unicode/Data.pm

filter: Statementstmt 63.7% 1034 / 1621 Branchbran 50.6% 473 / 934 Conditioncond 49.0% 717 / 1461 MC/DCmcdc 22.1% 156 / 703 Subroutinesub 75.1% 308 / 410 Podpod 96.5% 167 / 173 totaltotal 53.8% 2855 / 5302 CC 1005 SCAR 55.0
CC
1005
Cov
55%
_fetch_all
1838.5
pass_error
1310.5
calendar_era
600.0
CRAP 245.0
↑ Summary
1 ##----------------------------------------------------------------------------
2 ## Unicode Locale Identifier - ~/lib/m
3 ## Version v1.10.0
4 ## Copyright(c) 2026 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2024/06/15
7 ## Modified 2026/10/23
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 Locale::Unicode::Data;
14 BEGIN
15 7 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
16 7 ▶ use v5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 7 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 7 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 7 ▶ use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 7 ▶ use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 $ERROR $VERSION $DEBUG $FATAL_EXCEPTIONS
22 $CLDR_VERSION $DB_FILE $DBH $STHS $IS_CHILD_THREAD $RESOLVABLE
23 7 );
24 7 ▶ use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 7 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 7 ▶ use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 7 ▶ use DBD::SQLite;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 7 ▶ use DBI qw( :sql_types );
Subroutine BEGIN: called CC=1 SCAR=0.0
29 7 ▶ use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30 7 ▶ use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 7 ▶ use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 7 ▶ use Locale::Unicode v0.3.5;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 7 ▶ use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
34 7 ▶ use Wanted;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 7 ▶ use constant {
Subroutine BEGIN: called CC=3 SCAR=11.7
36 7 ▶ HAS_CONSTANTS => ( version->parse( $DBD::SQLite::VERSION ) >= 1.48 ? 1 : 0 ),
Branch: 2 branches
BranchTrueFalseTotal
'version'->parse($DBD::SQLite::VERSION) >= 1.48 ? : 7 0 7
'version'->parse($DBD::SQLite::VERSION) < 1.68 ? : 0 7 7
37 MISSING_AUTO_UTF8_DECODING => ( version->parse( $DBD::SQLite::VERSION ) < 1.68 ? 1 : 0 ),
38 7 };
39 7 our $CLDR_VERSION = '49';
40 7 our $DBH = {};
41 7 our $STHS = {};
42 7 our $IS_CHILD_THREAD = 0;
43 # The methods resolve() supports, with the table they query, and whether they return all the
44 # matching rows (an array reference) or only one (an hash reference).
45 7 our $RESOLVABLE =
46 {
47 calendar_append_format => { table => 'calendar_append_formats', all => 0 },
48 calendar_append_formats => { table => 'calendar_append_formats', all => 1 },
49 calendar_available_format => { table => 'calendar_available_formats', all => 0 },
50 calendar_available_formats => { table => 'calendar_available_formats', all => 1 },
51 calendar_cyclic_l10n => { table => 'calendar_cyclics_l10n', all => 0 },
52 calendar_cyclics_l10n => { table => 'calendar_cyclics_l10n', all => 1 },
53 calendar_datetime_format => { table => 'calendar_datetime_formats', all => 0 },
54 calendar_datetime_formats => { table => 'calendar_datetime_formats', all => 1 },
55 calendar_era_l10n => { table => 'calendar_eras_l10n', all => 0 },
56 calendar_eras_l10n => { table => 'calendar_eras_l10n', all => 1 },
57 calendar_format_l10n => { table => 'calendar_formats_l10n', all => 0 },
58 calendar_formats_l10n => { table => 'calendar_formats_l10n', all => 1 },
59 calendar_interval_format => { table => 'calendar_interval_formats', all => 0 },
60 calendar_interval_formats => { table => 'calendar_interval_formats', all => 1 },
61 calendar_term => { table => 'calendar_terms', all => 0 },
62 calendar_terms => { table => 'calendar_terms', all => 1 },
63 date_field_l10n => { table => 'date_fields_l10n', all => 0 },
64 date_fields_l10n => { table => 'date_fields_l10n', all => 1 },
65 date_term => { table => 'date_terms', all => 0 },
66 date_terms => { table => 'date_terms', all => 1 },
67 metazone_names => { table => 'metazones_names', all => 0 },
68 metazones_names => { table => 'metazones_names', all => 1 },
69 number_format_l10n => { table => 'number_formats_l10n', all => 0 },
70 number_formats_l10n => { table => 'number_formats_l10n', all => 1 },
71 number_symbol_l10n => { table => 'number_symbols_l10n', all => 0 },
72 number_symbols_l10n => { table => 'number_symbols_l10n', all => 1 },
73 person_name_format => { table => 'person_name_formats', all => 0 },
74 person_name_formats => { table => 'person_name_formats', all => 1 },
75 time_relative_l10n => { table => 'time_relative_l10n', all => 0 },
76 time_relatives_l10n => { table => 'time_relative_l10n', all => 1 },
77 unit_l10n => { table => 'units_l10n', all => 0 },
78 units_l10n => { table => 'units_l10n', all => 1 },
79 };
80 7 our $VERSION = 'v1.10.0';
81 };
82  
83 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
85  
86 {
87 7 my( $vol, $parent, $file ) = File::Spec->splitpath(__FILE__);
88 7 $DB_FILE = File::Spec->catpath( $vol, $parent, 'unicode_cldr.sqlite3' );
89 7 ▶ unless( File::Spec->file_name_is_absolute( $DB_FILE ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ("File::Spec"->file_name_is_absolute($Locale::Unicode::Data::DB_FILE)) 6 1 7
90 {
91 6 $DB_FILE = File::Spec->rel2abs( $DB_FILE );
92 }
93 }
94  
95 sub new
96 6 ▶{
Subroutine new: called CC=16 SCAR=35.4
Pod documented
97 6 my $this = shift( @_ );
98 6 ▶ my $self = bless( {} => ( ref( $this ) || $this ) );
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
060
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
99 6 $self->{datafile} = $DB_FILE;
100 6 $self->{decode_sql_arrays} = 1;
101 6 $self->{extend_timezones_cities} = 1;
102 6 ▶ $self->{fatal} = ( $FATAL_EXCEPTIONS // 0 );
Condition50%1/2
$Locale::Unicode::Data::FATAL_EXCEPTIONS // 0
l!l
06
MC/DC0%0/1
$Locale::Unicode::Data::FATAL_EXCEPTIONS // 0
$Locale::Unicode::Data::FATAL_EXCEPTIONS
Truth table50%1/2
A
A= $Locale::Unicode::Data::FATAL_EXCEPTIONS
Aresult
11
00
103 6 my @args = @_;
104 6 ▶ if( scalar( @args ) == 1 &&
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @args == 1 and defined $args[0] and ref $args[0] eq 'HASH') { } 0 6 6
elsif (scalar(@args) % 2) { } 0 6 6
Condition33%2/6
scalar @args == 1 and defined $args[0] and ref $args[0] eq "HASH"
!ll&&!rl&&r
600
scalar @args == 1 and defined $args[0]
!ll&&!rl&&r
600
MC/DC0%0/3
scalar @args == 1 and defined $args[0] and ref $args[0] eq "HASH"
scalar @args == 1 defined $args[0] ref $args[0] eq "HASH"
Truth table25%1/4
A and B and C
A= scalar @args == 1B= defined $args[0]C= ref $args[0] eq "HASH"
ABCresult
0XX0
10X0
1100
1111
105 defined( $args[0] ) &&
106 ref( $args[0] ) eq 'HASH' )
107 {
108 0 my $opts = shift( @args );
109 0 @args = %$opts;
110 }
111 elsif( ( scalar( @args ) % 2 ) )
112 {
113 0 return( $self->error( sprintf( "Uneven number of parameters provided (%d). Should receive key => value pairs. Parameters provided are: %s", scalar( @args ), join( ', ', @args ) ) ) );
114 }
115  
116 6 ▶ for( my $i = 0; $i < scalar( @args ); $i += 2 )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @args) 1 5 6
117 {
118 1 ▶ if( $args[$i] eq 'fatal' )
Branch: 1 branch
BranchTrueFalseTotal
if ($args[$i] eq "fatal") 1 0 1
119 {
120 1 $self->{fatal} = $args[$i + 1];
121 1 last;
122 }
123 }
124  
125 # Then, if the user provided with an hash or hash reference of options, we apply them
126 6 ▶ for( my $i = 0; $i < scalar( @args ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @args) 1 6 7
127 {
128 1 my $name = $args[ $i ];
129 1 my $val = $args[ ++$i ];
130 1 my $meth = $self->can( $name );
131 1 ▶ if( !defined( $meth ) )
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $meth) { } 0 1 1
elsif (not defined &$meth($self, $val)) { } 0 1 1
132 {
133 0 return( $self->error( "Unknown method \"${meth}\" provided." ) );
134 }
135 elsif( !defined( $meth->( $self, $val ) ) )
136 {
137 0 ▶ if( defined( $val ) && $self->error )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and $self->error) 0 0 0
Condition0%0/3
defined $val and $self->error
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and $self->error
defined $val $self->error
Truth table0%0/3
A and B
A= defined $valB= $self->error
ABresult
0X0
100
111
138 {
139 0 return( $self->pass_error );
140 }
141 }
142 }
143  
144 6 ▶ my $file = $self->{datafile} || return( $self->error( "No SQLite data file set." ) );
Condition50%1/2
$self->{'datafile'} || (return $self->error('No SQLite data file set.'))
l!l
60
MC/DC0%0/1
$self->{'datafile'} || (return $self->error('No SQLite data file set.'))
$self->{'datafile'}
Truth table50%1/2
A
A= $self->{'datafile'}
Aresult
11
00
145 # We test the connection to the database, but for threads safety, we do not store the database handle in our object. $self->_dbh returns a cached value anyway, and handles well threaded environments.
146 6 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition50%1/2
$self->_dbh || (return $self->pass_error)
l!l
60
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table50%1/2
A
A= $self->_dbh
Aresult
11
00
147 6 return( $self );
148 }
149  
150 48 ▶sub alias { return( shift->_fetch_one({
Subroutine alias: called CC=1 SCAR=0.0
Pod documented
151 48 id => 'get_alias',
152 field => 'alias',
153 table => 'aliases',
154 requires => [qw( type )],
155 has_array => [qw( replacement )],
156 }, @_ ) ); }
157  
158 6 ▶sub aliases { return( shift->_fetch_all({
Subroutine aliases: called CC=1 SCAR=0.0
Pod documented
159 6 id => 'aliases',
160 table => 'aliases',
161 by => [qw( type )],
162 has_array => [qw( replacement )],
163 }, @_ ) ); }
164  
165 1 ▶sub annotation { return( shift->_fetch_one({
Subroutine annotation: called CC=1 SCAR=0.0
Pod documented
166 1 id => 'get_annotation',
167 field => 'annotation',
168 table => 'annotations',
169 requires => [qw( locale )],
170 has_array => [qw( defaults )],
171 }, @_ ) ); }
172  
173 1 ▶sub annotations { return( shift->_fetch_all({
Subroutine annotations: called CC=1 SCAR=0.0
Pod documented
174 1 id => 'annotations',
175 table => 'annotations',
176 by => [qw( locale )],
177 has_array => [qw( defaults )],
178 }, @_ ) ); }
179  
180 1 ▶sub bcp47_currency { return( shift->_fetch_one({
Subroutine bcp47_currency: called CC=1 SCAR=0.0
Pod documented
181 1 id => 'get_bcp47_currency',
182 field => 'currid',
183 table => 'bcp47_currencies',
184 }, @_ ) ); }
185  
186 2 ▶sub bcp47_currencies { return( shift->_fetch_all({
Subroutine bcp47_currencies: called CC=1 SCAR=0.0
Pod documented
187 2 id => 'bcp47_currencies',
188 table => 'bcp47_currencies',
189 by => [qw( code is_obsolete )],
190 }, @_ ) ); }
191  
192 1 ▶sub bcp47_extension { return( shift->_fetch_one({
Subroutine bcp47_extension: called CC=1 SCAR=0.0
Pod documented
193 1 id => 'get_bcp47_extension',
194 field => 'extension',
195 table => 'bcp47_extensions',
196 }, @_ ) ); }
197  
198 2 ▶sub bcp47_extensions { return( shift->_fetch_all({
Subroutine bcp47_extensions: called CC=1 SCAR=0.0
Pod documented
199 2 id => 'bcp47_extensions',
200 table => 'bcp47_extensions',
201 by => [qw( extension deprecated )],
202 }, @_ ) ); }
203  
204 1 ▶sub bcp47_timezone { return( shift->_fetch_one({
Subroutine bcp47_timezone: called CC=1 SCAR=0.0
Pod documented
205 1 id => 'get_bcp47_timezone',
206 field => 'tzid',
207 table => 'bcp47_timezones',
208 has_array => [qw( alias )],
209 }, @_ ) ); }
210  
211 1 ▶sub bcp47_timezones { return( shift->_fetch_all({
Subroutine bcp47_timezones: called CC=1 SCAR=0.0
Pod documented
212 1 id => 'bcp47_timezones',
213 table => 'bcp47_timezones',
214 by => [qw( deprecated )],
215 has_array => [qw( alias )],
216 }, @_ ) ); }
217  
218 1 ▶sub bcp47_value { return( shift->_fetch_one({
Subroutine bcp47_value: called CC=1 SCAR=0.0
Pod documented
219 1 id => 'get_bcp47_value',
220 field => 'value',
221 table => 'bcp47_values',
222 }, @_ ) ); }
223  
224 2 ▶sub bcp47_values { return( shift->_fetch_all({
Subroutine bcp47_values: called CC=1 SCAR=0.0
Pod documented
225 2 id => 'bcp47_values',
226 table => 'bcp47_values',
227 by => [qw( category extension )],
228 }, @_ ) ); }
229  
230 1 ▶sub calendar { return( shift->_fetch_one({
Subroutine calendar: called CC=1 SCAR=0.0
Pod documented
231 1 id => 'get_calendar',
232 field => 'calendar',
233 table => 'calendars',
234 }, @_ ) ); }
235  
236 2 ▶sub calendars { return( shift->_fetch_all({
Subroutine calendars: called CC=1 SCAR=0.0
Pod documented
237 2 id => 'calendars',
238 table => 'calendars',
239 by => [qw( calendar system inherits )],
240 }, @_ ) ); }
241  
242 1 ▶sub calendar_append_format { return( shift->_fetch_one({
Subroutine calendar_append_format: called CC=1 SCAR=0.0
Pod documented
243 1 id => 'get_calendar_append_format',
244 field => 'format_id',
245 table => 'calendar_append_formats',
246 requires => [qw( locale calendar )],
247 }, @_ ) ); }
248  
249 3 ▶sub calendar_append_formats { return( shift->_fetch_all({
Subroutine calendar_append_formats: called CC=1 SCAR=0.0
Pod documented
250 3 id => 'calendar_append_formats',
251 table => 'calendar_append_formats',
252 by => [qw( locale calendar )],
253 }, @_ ) ); }
254  
255 1 ▶sub calendar_available_format { return( shift->_fetch_one({
Subroutine calendar_available_format: called CC=1 SCAR=0.0
Pod documented
256 1 id => 'get_calendar_available_format',
257 field => 'format_id',
258 table => 'calendar_available_formats',
259 requires => [qw( locale calendar count alt )],
260 default => { count => undef, alt => undef },
261 }, @_ ) ); }
262  
263 3 ▶sub calendar_available_formats { return( shift->_fetch_all({
Subroutine calendar_available_formats: called CC=1 SCAR=0.0
Pod documented
264 3 id => 'calendar_available_formats',
265 table => 'calendar_available_formats',
266 by => [qw( locale calendar count alt )],
267 }, @_ ) ); }
268  
269 1 ▶sub calendar_cyclic_l10n { return( shift->_fetch_one({
Subroutine calendar_cyclic_l10n: called CC=1 SCAR=0.0
Pod documented
270 1 id => 'get_calendar_cyclic_l10n',
271 field => 'format_id',
272 table => 'calendar_cyclics_l10n',
273 requires => [qw( locale calendar format_set format_type format_length )],
274 }, @_ ) ); }
275  
276 3 ▶sub calendar_cyclics_l10n { return( shift->_fetch_all({
Subroutine calendar_cyclics_l10n: called CC=1 SCAR=0.0
Pod documented
277 3 id => 'calendar_cyclics_l10n',
278 table => 'calendar_cyclics_l10n',
279 by => [qw( locale calendar format_set format_type format_length )],
280 }, @_ ) ); }
281  
282 1 ▶sub calendar_datetime_format { return( shift->_fetch_one({
Subroutine calendar_datetime_format: called CC=1 SCAR=0.0
Pod documented
283 1 id => 'get_calendar_datetime_format',
284 field => 'format_type',
285 table => 'calendar_datetime_formats',
286 requires => [qw( locale calendar format_length )],
287 }, @_ ) ); }
288  
289 3 ▶sub calendar_datetime_formats { return( shift->_fetch_all({
Subroutine calendar_datetime_formats: called CC=1 SCAR=0.0
Pod documented
290 3 id => 'calendar_datetime_formats',
291 table => 'calendar_datetime_formats',
292 by => [qw( locale calendar )],
293 }, @_ ) ); }
294  
295 sub calendar_era
296 0 ▶{
Subroutine calendar_era: not called CC=24 SCAR=64.0
Pod documented
297 0 my $self = shift( @_ );
298 0 my $opts = $self->_get_args_as_hash( @_ );
299 0 ▶ $opts->{calendar} || return( $self->error( "No calendar ID was provided." ) );
Branch: 1 branch
BranchTrueFalseTotal
$opts->{"calendar"} or return $self->error("No calendar ID was provided.") 0 0 0
300 0 ▶ if( $opts->{calendar} !~ /^[a-zA-Z]+(?:\-[a-zA-Z]+)*$/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"calendar"} =~ /^[a-zA-Z]+(?:\-[a-zA-Z]+)*$/) 0 0 0
301 {
302 0 return( $self->error( "Calendar ID provided '$opts->{calendar}' contains illegal characters." ) );
303 }
304 0 my $sql_arrays_in = [qw( aliases )];
305 0 my $sth;
306 0 local $@;
307 0 ▶ if( $opts->{sequence} )
Branch: 2 branches
BranchTrueFalseTotal
if ($opts->{'sequence'}) { } 0 0 0
elsif ($opts->{'code'}) { } 0 0 0
308 {
309 0 ▶ if( defined( $opts->{sequence} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts->{"sequence"} and not $opts->{"sequence"} =~ /^\d+$/) 0 0 0
Condition0%0/3
defined $opts->{"sequence"} and not $opts->{"sequence"} =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opts->{"sequence"} and not $opts->{"sequence"} =~ /^\d+$/
defined $opts->{"sequence"} not $opts->{"sequence"} =~ /^\d+$/
Truth table0%0/3
A and not(B)
A= defined $opts->{"sequence"}B= not $opts->{"sequence"} =~ /^\d+$/
ABresult
0X0
100
111
310 $opts->{sequence} !~ /^\d+$/ )
311 {
312 0 ▶ return( $self->error( "The calendar era sequence provided (", ( $opts->{sequence} // 'undef' ), ") does not look like an integer." ) );
Condition0%0/2
$opts->{"sequence"} // "undef"
l!l
00
MC/DC0%0/1
$opts->{"sequence"} // "undef"
$opts->{"sequence"}
Truth table0%0/2
A
A= $opts->{"sequence"}
Aresult
11
00
313 }
314 0 ▶ unless( $sth = $self->_get_cached_statement( 'calendar_era_with_sequence' ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement("calendar_era_with_sequence")) 0 0 0
315 {
316 0 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition0%0/2
$self->_dbh || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table0%0/2
A
A= $self->_dbh
Aresult
11
00
317 $sth = eval
318 0 ▶ {
Condition0%0/2
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ? AND sequence = ?') } } || (return $self->error('Unable to prepare SQL query to retrieve calendar era information for a given calendar and sequence: ', $@ || $dbh->errstr))
l!l
00
MC/DC0%0/1
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ? AND sequence = ?') } } || (return $self->error('Unable to prepare SQL query to retrieve calendar era information for a given calendar and sequence: ', $@ || $dbh->errstr))
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ? AND sequence = ?') } }
Truth table0%0/2
A
A= eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ? AND sequence = ?') } }
Aresult
11
00
319 0 ▶ $dbh->prepare( "SELECT * FROM calendar_eras WHERE calendar = ? AND sequence = ?" )
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
320 } || return( $self->error( "Unable to prepare SQL query to retrieve calendar era information for a given calendar and sequence: ", ( $@ || $dbh->errstr ) ) );
321 0 $self->_set_cached_statement( calendar_era_with_sequence => $sth );
322 }
323 eval
324 0 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute(@$opts{"calendar", "sequence"}) } } or return $self->error(qq[Error executing SQL query '$sth->{"Statement"}' to retrieve calendar era information for a given calendar and sequence: ], $@ || $sth->errstr) 0 0 0
325 0 ▶ $sth->execute( @$opts{qw( calendar sequence )} )
Condition0%0/3
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
326 } || return( $self->error( "Error executing SQL query '$sth->{Statement}' to retrieve calendar era information for a given calendar and sequence: ", ( $@ || $sth->errstr ) ) );
327 }
328 elsif( $opts->{code} )
329 {
330 0 ▶ if( defined( $opts->{code} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts->{"code"} and not $opts->{"code"} =~ /^[a-zA-Z]+(?:\-[a-zA-Z]+)*$/) 0 0 0
Condition0%0/3
defined $opts->{"code"} and not $opts->{"code"} =~ /^[a-zA-Z]+(?:\-[a-zA-Z]+)*$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opts->{"code"} and not $opts->{"code"} =~ /^[a-zA-Z]+(?:\-[a-zA-Z]+)*$/
defined $opts->{"code"} not $opts->{"code"} =~ /^[a-zA-Z]+(?:\-[a-zA-Z]+)*$/
Truth table0%0/3
A and not(B)
A= defined $opts->{"code"}B= not $opts->{"code"} =~ /^[a-zA-Z]+(?:\-[a-zA-Z]+)*$/
ABresult
0X0
100
111
331 $opts->{code} !~ /^[a-zA-Z]+(?:\-[a-zA-Z]+)*$/ )
332 {
333 0 ▶ return( $self->error( "The calendar era code provided (", ( $opts->{code} // 'undef' ), ") contains illegal characters." ) );
Condition0%0/2
$opts->{"code"} // "undef"
l!l
00
MC/DC0%0/1
$opts->{"code"} // "undef"
$opts->{"code"}
Truth table0%0/2
A
A= $opts->{"code"}
Aresult
11
00
334 }
335 0 ▶ unless( $sth = $self->_get_cached_statement( 'calendar_era_with_code' ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement("calendar_era_with_code")) 0 0 0
336 {
337 0 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition0%0/2
$self->_dbh || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table0%0/2
A
A= $self->_dbh
Aresult
11
00
338 $sth = eval
339 0 ▶ {
Condition0%0/2
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ? AND code = ?') } } || (return $self->error('Unable to prepare SQL query to retrieve calendar era information for a given calendar and code: ', $@ || $dbh->errstr))
l!l
00
MC/DC0%0/1
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ? AND code = ?') } } || (return $self->error('Unable to prepare SQL query to retrieve calendar era information for a given calendar and code: ', $@ || $dbh->errstr))
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ? AND code = ?') } }
Truth table0%0/2
A
A= eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ? AND code = ?') } }
Aresult
11
00
340 0 ▶ $dbh->prepare( "SELECT * FROM calendar_eras WHERE calendar = ? AND code = ?" )
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
341 } || return( $self->error( "Unable to prepare SQL query to retrieve calendar era information for a given calendar and code: ", ( $@ || $dbh->errstr ) ) );
342 0 $self->_set_cached_statement( calendar_era_with_code => $sth );
343 }
344 eval
345 0 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute(@$opts{"calendar", "code"}) } } or return $self->error(qq[Error executing SQL query '$sth->{"Statement"}' to retrieve calendar era information for a given calendar and code: ], $@ || $sth->errstr) 0 0 0
346 0 ▶ $sth->execute( @$opts{qw( calendar code )} )
Condition0%0/3
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
347 } || return( $self->error( "Error executing SQL query '$sth->{Statement}' to retrieve calendar era information for a given calendar and code: ", ( $@ || $sth->errstr ) ) );
348 }
349 else
350 {
351 0 return( $self->error( "No sequence or code parameter provided to retrieve specific era for calendar $opts->{calendar}" ) );
352 }
353 0 my $ref = $sth->fetchrow_hashref;
354 0 $self->_decode_utf8( $ref ) if( MISSING_AUTO_UTF8_DECODING );
355 0 ▶ $self->_decode_sql_arrays( $sql_arrays_in, $ref ) if( $self->{decode_sql_arrays} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"decode_sql_arrays"} 0 0 0
356 0 return( $ref );
357 }
358  
359 sub calendar_eras
360 0 ▶{
Subroutine calendar_eras: not called CC=16 SCAR=56.1
Pod documented
361 0 my $self = shift( @_ );
362 0 my $opts = $self->_get_args_as_hash( @_ );
363 0 my $sql_arrays_in = [qw( aliases )];
364 0 my $sth;
365 0 local $@;
366 0 ▶ if( $opts->{calendar} )
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'calendar'}) { } 0 0 0
367 {
368 0 ▶ unless( $sth = $self->_get_cached_statement( 'calendar_eras_with_calendar' ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement("calendar_eras_with_calendar")) 0 0 0
369 {
370 0 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition0%0/2
$self->_dbh || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table0%0/2
A
A= $self->_dbh
Aresult
11
00
371 $sth = eval
372 0 ▶ {
Condition0%0/2
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ?') } } || (return $self->error(q[Unable to prepare SQL query to retrieve all calendar eras information for a given calendar': ], $@ || $dbh->errstr))
l!l
00
MC/DC0%0/1
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ?') } } || (return $self->error(q[Unable to prepare SQL query to retrieve all calendar eras information for a given calendar': ], $@ || $dbh->errstr))
eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ?') } }
Truth table0%0/2
A
A= eval { do { $dbh->prepare('SELECT * FROM calendar_eras WHERE calendar = ?') } }
Aresult
11
00
373 0 ▶ $dbh->prepare( "SELECT * FROM calendar_eras WHERE calendar = ?" )
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
374 } || return( $self->error( "Unable to prepare SQL query to retrieve all calendar eras information for a given calendar': ", ( $@ || $dbh->errstr ) ) );
375 0 $self->_set_cached_statement( calendar_eras_with_calendar => $sth );
376 }
377 }
378 else
379 {
380 0 ▶ unless( $sth = $self->_get_cached_statement( 'calendar_eras' ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement("calendar_eras")) 0 0 0
381 {
382 0 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition0%0/2
$self->_dbh || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table0%0/2
A
A= $self->_dbh
Aresult
11
00
383 $sth = eval
384 0 ▶ {
Condition0%0/2
eval { do { $dbh->prepare('SELECT * FROM calendar_eras') } } || (return $self->error('Unable to prepare SQL query to retrieve all calendar eras information: ', $@ || $dbh->errstr))
l!l
00
MC/DC0%0/1
eval { do { $dbh->prepare('SELECT * FROM calendar_eras') } } || (return $self->error('Unable to prepare SQL query to retrieve all calendar eras information: ', $@ || $dbh->errstr))
eval { do { $dbh->prepare('SELECT * FROM calendar_eras') } }
Truth table0%0/2
A
A= eval { do { $dbh->prepare('SELECT * FROM calendar_eras') } }
Aresult
11
00
385 0 ▶ $dbh->prepare( "SELECT * FROM calendar_eras" )
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
386 } || return( $self->error( "Unable to prepare SQL query to retrieve all calendar eras information: ", ( $@ || $dbh->errstr ) ) );
387 0 $self->_set_cached_statement( calendar_eras => $sth );
388 }
389 }
390  
391 eval
392 {
393 0 ▶ $sth->execute( length( $opts->{calendar} // '' ) ? $opts->{calendar} : () )
Branch: 2 branches
BranchTrueFalseTotal
length($opts->{'calendar'} // '') ? : 0 0 0
$opts->{'calendar'} ? : 0 0 0
Condition0%0/5
$opts->{"calendar"} // ""
l!l
00
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/1
$opts->{"calendar"} // ""
$opts->{"calendar"}
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/2
A
A= $opts->{"calendar"}
Aresult
11
00
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
394 0 ▶ } || return( $self->error( "Error executing SQL query '$sth->{Statement}' to retrieve all calendar eras". ( $opts->{calendar} ? " with calendar '$opts->{calendar}'" : '' ), ": ", ( $@ || $sth->errstr ) ) );
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute(length($opts->{"calendar"} // "") ? $opts->{"calendar"} : ()) } } or return $self->error(qq[Error executing SQL query '$sth->{"Statement"}' to retrieve all calendar eras] . ($opts->{"calendar"} ? qq[ with calendar '$opts->{"calendar"}'] : ""), ": ", $@ || $sth->errstr) 0 0 0
395 0 my $all = $sth->fetchall_arrayref({});
396 0 $self->_decode_utf8( $all ) if( MISSING_AUTO_UTF8_DECODING );
397 0 ▶ $self->_decode_sql_arrays( $sql_arrays_in, $all ) if( $self->{decode_sql_arrays} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"decode_sql_arrays"} 0 0 0
398 0 return( $all );
399 }
400  
401 1 ▶sub calendar_era_l10n { return( shift->_fetch_one({
Subroutine calendar_era_l10n: called CC=1 SCAR=0.0
Pod documented
402 1 id => 'get_calendar_era_l10n',
403 field => 'era_id',
404 table => 'calendar_eras_l10n',
405 requires => [qw( locale calendar era_width alt )],
406 default => { alt => undef },
407 }, @_ ) ); }
408  
409 7 ▶sub calendar_eras_l10n { return( shift->_fetch_all({
Subroutine calendar_eras_l10n: called CC=1 SCAR=0.0
Pod documented
410 7 id => 'calendar_eras_l10n',
411 table => 'calendar_eras_l10n',
412 by => [qw( locale calendar era_width alt )],
413 order => 'era_id',
414 }, @_ ) ); }
415  
416 1 ▶sub calendar_format_l10n { return( shift->_fetch_one({
Subroutine calendar_format_l10n: called CC=1 SCAR=0.0
Pod documented
417 1 id => 'get_calendar_format_l10n',
418 field => 'format_length',
419 table => 'calendar_formats_l10n',
420 requires => [qw( locale calendar format_type )],
421 }, @_ ) ); }
422  
423 3 ▶sub calendar_formats_l10n { return( shift->_fetch_all({
Subroutine calendar_formats_l10n: called CC=1 SCAR=0.0
Pod documented
424 3 id => 'calendar_formats_l10n',
425 table => 'calendar_formats_l10n',
426 by => [qw( locale calendar format_type format_length alt )],
427 }, @_ ) ); }
428  
429 1 ▶sub calendar_interval_format { return( shift->_fetch_one({
Subroutine calendar_interval_format: called CC=1 SCAR=0.0
Pod documented
430 1 id => 'get_calendar_interval_format',
431 field => 'format_id',
432 table => 'calendar_interval_formats',
433 requires => [qw( locale calendar greatest_diff_id alt )],
434 default => { alt => undef },
435 }, @_ ) ); }
436  
437 3 ▶sub calendar_interval_formats { return( shift->_fetch_all({
Subroutine calendar_interval_formats: called CC=1 SCAR=0.0
Pod documented
438 3 id => 'calendar_interval_formats',
439 table => 'calendar_interval_formats',
440 by => [qw( locale calendar greatest_diff_id alt )],
441 }, @_ ) ); }
442  
443 1 ▶sub calendar_l10n { return( shift->_fetch_one({
Subroutine calendar_l10n: called CC=1 SCAR=0.0
Pod documented
444 1 id => 'get_calendar_l10n',
445 field => 'calendar',
446 table => 'calendars_l10n',
447 requires => [qw( locale )],
448 default => { count => undef },
449 }, @_ ) ); }
450  
451 1 ▶sub calendars_l10n { return( shift->_fetch_all({
Subroutine calendars_l10n: called CC=1 SCAR=0.0
Pod documented
452 1 id => 'calendars_l10n',
453 table => 'calendars_l10n',
454 by => [qw( locale )],
455 }, @_ ) ); }
456  
457 2 ▶sub calendar_term { return( shift->_fetch_one({
Subroutine calendar_term: called CC=1 SCAR=0.0
Pod documented
458 # id => 'get_calendar_term',
459 2 field => 'term_name',
460 table => 'calendar_terms',
461 requires => [qw( locale calendar term_context term_width alt yeartype )],
462 default => { alt => undef, yeartype => undef },
463 }, @_ ) ); }
464  
465 # NOTE: no calendar_term() method, because filtering would return more than one element
466 12 ▶sub calendar_terms { return( shift->_fetch_all({
Subroutine calendar_terms: called CC=1 SCAR=0.0
Pod documented
467 12 id => 'calendars',
468 table => 'calendar_terms',
469 by => [qw( locale calendar term_type term_context term_width alt yeartype )],
470 }, @_ ) ); }
471  
472 1 ▶sub casing { return( shift->_fetch_one({
Subroutine casing: called CC=1 SCAR=0.0
Pod documented
473 1 id => 'get_casing',
474 field => 'token',
475 table => 'casings',
476 requires => [qw( locale )],
477 }, @_ ) ); }
478  
479 1 ▶sub casings { return( shift->_fetch_all({
Subroutine casings: called CC=1 SCAR=0.0
Pod documented
480 1 id => 'casings',
481 table => 'casings',
482 by => [qw( locale )],
483 }, @_ ) ); }
484  
485 0 ▶sub cldr_built { return( shift->_get_metadata( 'built_on' ) ); }
Subroutine cldr_built: not called CC=1 SCAR=6.9
Pod documented
486  
487 0 ▶sub cldr_maintainer { return( shift->_get_metadata( 'maintainer' ) ); }
Subroutine cldr_maintainer: not called CC=1 SCAR=6.9
Pod documented
488  
489 1 ▶sub cldr_version { return( shift->_get_metadata( 'cldr_version' ) ); }
Subroutine cldr_version: called CC=1 SCAR=0.0
Pod documented
490  
491 1 ▶sub code_mapping { return( shift->_fetch_one({
Subroutine code_mapping: called CC=1 SCAR=0.0
Pod documented
492 1 id => 'get_code_mapping',
493 field => 'code',
494 table => 'code_mappings',
495 }, @_ ) ); }
496  
497 6 ▶sub code_mappings { return( shift->_fetch_all({
Subroutine code_mappings: called CC=1 SCAR=0.0
Pod documented
498 6 id => 'code_mappings',
499 table => 'code_mappings',
500 by => [qw( alpha3 numeric fips10 type )],
501 }, @_ ) ); }
502  
503 1 ▶sub collation { return( shift->_fetch_one({
Subroutine collation: called CC=1 SCAR=0.0
Pod documented
504 1 id => 'get_collation',
505 field => 'collation',
506 table => 'collations',
507 }, @_ ) ); }
508  
509 1 ▶sub collations { return( shift->_fetch_all({
Subroutine collations: called CC=1 SCAR=0.0
Pod documented
510 1 id => 'collations',
511 table => 'collations',
512 by => [qw( collation description )],
513 # Important, because this is a view, and without explicitly defining the ordering field, it would fall back to rowid, which does not exist in view and would result in a fatal exception.
514 order => 'collation',
515 }, @_ ) ); }
516  
517 1 ▶sub collation_l10n { return( shift->_fetch_one({
Subroutine collation_l10n: called CC=1 SCAR=0.0
Pod documented
518 1 id => 'get_collation_l10n',
519 field => 'collation',
520 table => 'collations_l10n',
521 requires => [qw( locale )],
522 }, @_ ) ); }
523  
524 1 ▶sub collations_l10n { return( shift->_fetch_all({
Subroutine collations_l10n: called CC=1 SCAR=0.0
Pod documented
525 1 id => 'collations_l10n',
526 table => 'collations_l10n',
527 by => [qw( locale collation locale_name )],
528 }, @_ ) ); }
529  
530 1 ▶sub currency { return( shift->_fetch_one({
Subroutine currency: called CC=1 SCAR=0.0
Pod documented
531 1 id => 'get_currency',
532 field => 'currency',
533 table => 'currencies',
534 }, @_ ) ); }
535  
536 1 ▶sub currencies { return( shift->_fetch_all({
Subroutine currencies: called CC=1 SCAR=0.0
Pod documented
537 1 id => 'currencies',
538 table => 'currencies',
539 by => [qw( is_obsolete )],
540 has_status => 1,
541 }, @_ ) ); }
542  
543 1 ▶sub currency_info { return( shift->_fetch_one({
Subroutine currency_info: called CC=1 SCAR=0.0
Pod documented
544 1 id => 'get_currency_info',
545 field => 'currency',
546 table => 'currencies_info',
547 requires => [qw( territory )],
548 }, @_ ) ); }
549  
550 2 ▶sub currencies_info { return( shift->_fetch_all({
Subroutine currencies_info: called CC=1 SCAR=0.0
Pod documented
551 2 id => 'currencies',
552 table => 'currencies_info',
553 by => [qw( territory currency )],
554 }, @_ ) ); }
555  
556 1 ▶sub currency_l10n { return( shift->_fetch_one({
Subroutine currency_l10n: called CC=1 SCAR=0.0
Pod documented
557 1 id => 'get_currency_l10n',
558 field => 'currency',
559 table => 'currencies_l10n',
560 requires => [qw( locale count )],
561 default => { count => undef },
562 }, @_ ) ); }
563  
564 2 ▶sub currencies_l10n { return( shift->_fetch_all({
Subroutine currencies_l10n: called CC=1 SCAR=0.0
Pod documented
565 2 id => 'currencies_l10n',
566 table => 'currencies_l10n',
567 by => [qw( locale currency count )],
568 }, @_ ) ); }
569  
570 1 ▶sub database_handler { return( Scalar::Util::blessed( $_[0] ) ? shift->_dbh : undef ); }
Subroutine database_handler: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[0]) ? : 1 0 1
571  
572 1426 ▶sub datafile { return( shift->_set_get_prop( 'datafile', @_ ) ); }
Subroutine datafile: called CC=1 SCAR=0.0
Pod documented
573  
574 1 ▶sub data_alias { return( shift->_fetch_one({
Subroutine data_alias: called CC=1 SCAR=0.0
Pod documented
575 1 id => 'get_data_alias',
576 field => 'source',
577 table => 'data_aliases',
578 requires => [qw( locale table_name )],
579 }, @_ ) ); }
580  
581 4 ▶sub data_aliases { return( shift->_fetch_all({
Subroutine data_aliases: called CC=1 SCAR=0.0
Pod documented
582 4 id => 'data_aliases',
583 table => 'data_aliases',
584 by => [qw( locale table_name )],
585 }, @_ ) ); }
586  
587 1 ▶sub date_field_l10n { return( shift->_fetch_one({
Subroutine date_field_l10n: called CC=1 SCAR=0.0
Pod documented
588 1 id => 'get_date_field_l10n',
589 field => 'relative',
590 table => 'date_fields_l10n',
591 requires => [qw( locale field_type field_length )],
592 }, @_ ) ); }
593  
594 2 ▶sub date_fields_l10n { return( shift->_fetch_all({
Subroutine date_fields_l10n: called CC=1 SCAR=0.0
Pod documented
595 2 id => 'date_fields_l10n',
596 table => 'date_fields_l10n',
597 by => [qw( locale field_type field_length )],
598 }, @_ ) ); }
599  
600 0 ▶sub date_term { return( shift->_fetch_one({
Subroutine date_term: not called CC=1 SCAR=6.9
Pod documented
601 0 id => 'get_date_term',
602 field => 'term_type',
603 table => 'date_terms',
604 requires => [qw( locale term_length )],
605 }, @_ ) ); }
606  
607 0 ▶sub date_terms { return( shift->_fetch_all({
Subroutine date_terms: not called CC=1 SCAR=6.9
Pod documented
608 0 id => 'date_terms',
609 table => 'date_terms',
610 by => [qw( locale term_type term_length )],
611 }, @_ ) ); }
612  
613 1 ▶sub day_period { return( shift->_fetch_one({
Subroutine day_period: called CC=1 SCAR=0.0
Pod documented
614 1 id => 'get_day_period',
615 field => 'day_period',
616 table => 'day_periods',
617 requires => [qw( locale )],
618 }, @_ ) ); }
619  
620 2 ▶sub day_periods { return( shift->_fetch_all({
Subroutine day_periods: called CC=1 SCAR=0.0
Pod documented
621 2 id => 'day_periods',
622 table => 'day_periods',
623 by => [qw( locale day_period )],
624 }, @_ ) ); }
625  
626 0 ▶sub decode_sql_arrays { return( shift->_set_get_prop({
Subroutine decode_sql_arrays: not called CC=1 SCAR=6.9
Pod documented
627 0 field => 'decode_sql_arrays',
628 type => 'boolean',
629 }, @_ ) ); }
630  
631 sub error
632 7 ▶{
Subroutine error: called CC=7 SCAR=19.9
Pod documented
633 7 my $self = shift( @_ );
634 7 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 4 7
635 {
636 3 ▶ my $msg = join( '', map( ( ref( $_ ) eq 'CODE' ) ? $_->() : $_, @_ ) );
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'CODE' ? : 0 3 3
637 3 $self->{error} = $ERROR = Locale::Unicode::Data::Exception->new({
638 skip_frames => 1,
639 message => $msg,
640 });
641 3 ▶ if( $self->fatal )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->fatal) { } 1 2 3
642 {
643 1 die( $self->{error} );
644 }
645 else
646 {
647 2 ▶ warn( $msg ) if( warnings::enabled() );
Branch: 1 branch
BranchTrueFalseTotal
if warnings::enabled() 2 0 2
648 2 ▶ rreturn( Locale::Unicode::Data::NullObject->new ) if( want( 'OBJECT' ) );
Branch: 1 branch
BranchTrueFalseTotal
if want("OBJECT") 0 2 2
649 2 return;
650 }
651 }
652 4 ▶ return( ref( $self ) ? $self->{error} : $ERROR );
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 4 0 4
653 }
654  
655 1 ▶sub extend_timezones_cities { return( shift->_set_get_prop({
Subroutine extend_timezones_cities: called CC=1 SCAR=0.0
Pod documented
656 1 field => 'extend_timezones_cities',
657 type => 'boolean',
658 }, @_ ) ); }
659  
660 4 ▶sub fatal { return( shift->_set_get_prop( 'fatal', @_ ) ); }
Subroutine fatal: called CC=1 SCAR=0.0
Pod documented
661  
662 sub interval_formats
663 0 ▶{
Subroutine interval_formats: not called CC=6 SCAR=37.4
Pod documented
664 0 my $self = shift( @_ );
665 0 my $opts = $self->_get_args_as_hash( @_ );
666 my $locale = $opts->{locale} ||
667 0 ▶ return( $self->error( "No locale provided to get all the interval formats." ) );
Condition0%0/2
$opts->{'locale'} || (return $self->error('No locale provided to get all the interval formats.'))
l!l
00
MC/DC0%0/1
$opts->{'locale'} || (return $self->error('No locale provided to get all the interval formats.'))
$opts->{'locale'}
Truth table0%0/2
A
A= $opts->{'locale'}
Aresult
11
00
668 my $cal_id = $opts->{calendar} ||
669 0 ▶ return( $self->error( "No calendar ID provided to get all the interval formats." ) );
Condition0%0/2
$opts->{'calendar'} || (return $self->error('No calendar ID provided to get all the interval formats.'))
l!l
00
MC/DC0%0/1
$opts->{'calendar'} || (return $self->error('No calendar ID provided to get all the interval formats.'))
$opts->{'calendar'}
Truth table0%0/2
A
A= $opts->{'calendar'}
Aresult
11
00
670 0 ▶ my $all = $self->calendar_interval_formats(
Condition0%0/2
$self->calendar_interval_formats('locale', $locale, 'calendar', $cal_id) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->calendar_interval_formats('locale', $locale, 'calendar', $cal_id) || (return $self->pass_error)
$self->calendar_interval_formats('locale', $locale, 'calendar', $cal_id)
Truth table0%0/2
A
A= $self->calendar_interval_formats('locale', $locale, 'calendar', $cal_id)
Aresult
11
00
671 locale => $locale,
672 calendar => $cal_id,
673 ) || return( $self->pass_error );
674 0 my $formats = {};
675 0 foreach my $ref ( @$all )
676 {
677 0 ▶ $formats->{ $ref->{format_id} } ||= [];
Condition0%0/2
$$formats{$ref->{"format_id"}} ||= []
l!l
00
MC/DC0%0/1
$$formats{$ref->{"format_id"}} ||= []
$$formats{$ref->{"format_id"}}
Truth table0%0/2
A
A= $$formats{$ref->{"format_id"}}
Aresult
11
00
678 0 push( @{$formats->{ $ref->{format_id} }}, $ref->{greatest_diff_id} );
679 }
680 0 return( $formats );
681 }
682  
683 sub l10n
684 19 ▶{
Subroutine l10n: called CC=24 SCAR=38.3
Pod documented
685 19 my $self = shift( @_ );
686 19 my $opts = $self->_get_args_as_hash( @_ );
687 19 ▶ my $type = $opts->{type} || return( $self->error( "No localisation type was provided." ) );
Condition50%1/2
$opts->{'type'} || (return $self->error('No localisation type was provided.'))
l!l
190
MC/DC0%0/1
$opts->{'type'} || (return $self->error('No localisation type was provided.'))
$opts->{'type'}
Truth table50%1/2
A
A= $opts->{'type'}
Aresult
11
00
688 19 my $type_to_table =
689 {
690 annotation =>
691 {
692 table => 'annotations',
693 field => 'annotation',
694 has_array => [qw( defaults )],
695 },
696 calendar_append_format =>
697 {
698 table => 'calendar_append_formats',
699 field => 'format_id',
700 requires => [qw( locale calendar )],
701 },
702 calendar_available_format =>
703 {
704 table => 'calendar_available_formats',
705 field => 'format_id',
706 requires => [qw( locale calendar )],
707 },
708 calendar_cyclic =>
709 {
710 table => 'calendar_cyclics_l10n',
711 field => 'format_id',
712 requires => [qw( locale calendar format_set )],
713 },
714 calendar_era =>
715 {
716 table => 'calendar_eras_l10n',
717 field => 'era_id',
718 requires => [qw( locale calendar era_width )],
719 },
720 calendar_format =>
721 {
722 table => 'calendar_formats_l10n',
723 field => 'format_id',
724 requires => [qw( locale calendar )],
725 },
726 calendar_interval_format =>
727 {
728 table => 'calendar_interval_formats',
729 field => 'format_id',
730 requires => [qw( locale calendar )],
731 },
732 calendar_term =>
733 {
734 table => 'calendar_terms',
735 field => 'term_name',
736 requires => [qw( locale calendar )],
737 },
738 casing =>
739 {
740 table => 'casings',
741 field => 'token',
742 },
743 currency =>
744 {
745 table => 'currencies_l10n',
746 field => 'currency',
747 },
748 date_field =>
749 {
750 table => 'date_fields_l10n',
751 field => 'relative',
752 requires => [qw( locale field_type )],
753 },
754 locale =>
755 {
756 table => 'locales_l10n',
757 field => 'locale_id',
758 },
759 number_format =>
760 {
761 table => 'number_formats_l10n',
762 field => 'format_id',
763 requires => [qw( locale number_type )],
764 },
765 number_symbol =>
766 {
767 table => 'number_symbols_l10n',
768 field => 'property',
769 },
770 script =>
771 {
772 table => 'scripts_l10n',
773 field => 'script',
774 },
775 subdivision =>
776 {
777 table => 'subdivisions_l10n',
778 field => 'subdivision',
779 },
780 territory =>
781 {
782 table => 'territories_l10n',
783 field => 'territory',
784 },
785 unit =>
786 {
787 table => 'units_l10n',
788 field => 'unit_id',
789 },
790 variant =>
791 {
792 table => 'variants_l10n',
793 field => 'variant',
794 },
795 };
796 19 $type_to_table->{era} = $type_to_table->{calendar_era};
797 19 $type_to_table->{available} = $type_to_table->{calendar_available_format};
798 19 $type_to_table->{append} = $type_to_table->{calendar_append_format};
799 19 $type_to_table->{cyclic} = $type_to_table->{calendar_cyclics_l10n};
800 19 $type_to_table->{field} = $type_to_table->{date_field};
801 19 $type_to_table->{interval} = $type_to_table->{calendar_interval_format};
802 19 $type_to_table->{symbol} = $type_to_table->{number_symbol};
803 19 ▶ if( !exists( $type_to_table->{ $type } ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $type_to_table->{$type}) 0 19 19
804 {
805 0 return( $self->error( "Unknown localisation type '${type}'" ) );
806 }
807 19 my $table = $type_to_table->{ $type }->{table};
808 19 my $field = $type_to_table->{ $type }->{field};
809 19 my $key;
810 19 ▶ if( exists( $opts->{key} ) )
Branch: 2 branches
BranchTrueFalseTotal
if (exists $opts->{'key'}) { } 0 19 19
elsif (exists $opts->{$field}) { } 19 0 19
811 {
812 0 $key = $opts->{key};
813 }
814 elsif( exists( $opts->{ $field } ) )
815 {
816 19 $key = $opts->{ $field };
817 }
818 19 ▶ return( $self->error( "No localisation key was provided." ) ) if( !defined( $key ) || !length( $key // '' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key and length($key // "") 0 19 19
Condition40%2/5
defined $key and length($key // "")
!ll&&!rl&&r
0019
$key // ""
l!l
190
MC/DC0%0/2
defined $key and length($key // "")
defined $key $key
Truth table33%1/3
A and B
A= defined $keyB= $key
ABresult
0X0
100
111
819 my $requires = exists( $type_to_table->{ $type }->{requires} )
820 ? $type_to_table->{ $type }->{requires}
821 19 ▶ : [qw( locale )];
Branch: 1 branch
BranchTrueFalseTotal
exists $type_to_table->{$type}{'requires'} ? : 9 10 19
822 19 foreach( @$requires )
823 {
824 30 ▶ if( !exists( $opts->{ $_ } ) ||
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $opts->{$_} and defined $opts->{$_} and length($opts->{$_} // "")) 0 30 30
Condition37%3/8
exists $opts->{$_} and defined $opts->{$_} and length($opts->{$_} // "")
!ll&&!rl&&r
0030
exists $opts->{$_} and defined $opts->{$_}
!ll&&!rl&&r
0030
$opts->{$_} // ""
l!l
300
MC/DC0%0/3
exists $opts->{$_} and defined $opts->{$_} and length($opts->{$_} // "")
exists $opts->{$_} defined $opts->{$_} $opts->{$_}
Truth table25%1/4
A and B and C
A= exists $opts->{$_}B= defined $opts->{$_}C= $opts->{$_}
ABCresult
0XX0
10X0
1100
1111
825 !defined( $opts->{ $_ } ) ||
826 !length( $opts->{ $_ } // '' ) )
827 {
828 0 return( $self->error( "No value provided for argument '$_' to retrieve localised data from table ${table}" ) );
829 }
830 }
831 19 local $@;
832 19 my $sth;
833 19 ▶ my $sth_id = "l10n_${table}" . ( scalar( @$requires ) ? '_' . join( '_', @$requires ) : '' );
Branch: 1 branch
BranchTrueFalseTotal
scalar @$requires ? : 19 0 19
834 19 ▶ unless( $sth = $self->_get_cached_statement( $sth_id ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement($sth_id)) 19 0 19
835 {
836 19 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition50%1/2
$self->_dbh || (return $self->pass_error)
l!l
190
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table50%1/2
A
A= $self->_dbh
Aresult
11
00
837 $sth = eval
838 19 ▶ {
Condition50%1/2
eval { do { $dbh->prepare("SELECT * FROM $table WHERE $field = ?" . (scalar @$requires ? ' AND ' . join(' AND ', map(("$_ = ?"), @$requires)) : '') . ' ORDER BY rowid') } } || (return $self->error("Unable to prepare SQL query to retrieve data from the table $table with field ${field}: ", $@ || $dbh->errstr))
l!l
190
MC/DC0%0/1
eval { do { $dbh->prepare("SELECT * FROM $table WHERE $field = ?" . (scalar @$requires ? ' AND ' . join(' AND ', map(("$_ = ?"), @$requires)) : '') . ' ORDER BY rowid') } } || (return $self->error("Unable to prepare SQL query to retrieve data from the table $table with field ${field}: ", $@ || $dbh->errstr))
eval { do { $dbh->prepare("SELECT * FROM $table WHERE $field = ?" . (scalar @$requires ? ' AND ' . join(' AND ', map(("$_ = ?"), @$requires)) : '') . ' ORDER BY rowid') } }
Truth table50%1/2
A
A= eval { do { $dbh->prepare("SELECT * FROM $table WHERE $field = ?" . (scalar @$requires ? ' AND ' . join(' AND ', map(("$_ = ?"), @$requires)) : '') . ' ORDER BY rowid') } }
Aresult
11
00
839 19 ▶ $dbh->prepare( "SELECT * FROM ${table} WHERE ${field} = ?" . ( scalar( @$requires ) ? ' AND ' . join( ' AND ', map( "$_ = ?", @$requires ) ) : '' ) . ' ORDER BY rowid' );
Branch: 1 branch
BranchTrueFalseTotal
scalar @$requires ? : 19 0 19
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
840 } || return( $self->error( "Unable to prepare SQL query to retrieve data from the table ${table} with field ${field}: ", ( $@ || $dbh->errstr ) ) );
841 19 $self->_set_cached_statement( $sth_id => $sth );
842 }
843 eval
844 {
845 19 ▶ $sth->execute( $key, @$opts{ @$requires } );
Condition0%0/3
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
846 19 ▶ } || return( $self->error( "Error executing SQL statement to retrieve data from the table ${table} with field ${field} and arguments '", join( "', '", @$requires ), "': ", ( $@ || $sth->errstr ), " with SQL query: ", $sth->{Statement} ) );
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute($key, @$opts{@$requires}) } } or return $self->error("Error executing SQL statement to retrieve data from the table $table with field $field and arguments '", join("', '", @$requires), "': ", $@ || $sth->errstr, " with SQL query: ", $sth->{"Statement"}) 19 0 19
847 19 my $all = $sth->fetchall_arrayref({});
848 19 $self->_decode_utf8( $all ) if( MISSING_AUTO_UTF8_DECODING );
849 19 ▶ if( exists( $type_to_table->{ $type }->{has_array} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $type_to_table->{$type}{"has_array"} and $self->{"decode_sql_arrays"}) 1 18 19
Condition66%2/3
exists $type_to_table->{$type}{"has_array"} and $self->{"decode_sql_arrays"}
!ll&&!rl&&r
1801
MC/DC50%1/2
exists $type_to_table->{$type}{"has_array"} and $self->{"decode_sql_arrays"}
exists $type_to_table->{$type}{"has_array"} $self->{"decode_sql_arrays"}
Truth table66%2/3
A and B
A= exists $type_to_table->{$type}{"has_array"}B= $self->{"decode_sql_arrays"}
ABresult
0X0
100
111
850 $self->{decode_sql_arrays} )
851 {
852 1 $self->_decode_sql_arrays( $type_to_table->{ $type }->{has_array}, $all );
853 }
854 19 return( $all );
855 }
856  
857 1 ▶sub language { return( shift->_fetch_one({
Subroutine language: called CC=1 SCAR=0.0
Pod documented
858 1 id => 'get_language',
859 field => 'language',
860 table => 'languages',
861 has_array => [qw( scripts territories )],
862 }, @_ ) ); }
863  
864 1 ▶sub languages { return( shift->_fetch_all({
Subroutine languages: called CC=1 SCAR=0.0
Pod documented
865 1 id => 'languages',
866 table => 'languages',
867 by => [qw( parent alt )],
868 has_status => 1,
869 has_array => [qw( scripts territories )],
870 }, @_ ) ); }
871  
872 0 ▶sub language_population { return( shift->_fetch_one({
Subroutine language_population: not called CC=1 SCAR=6.9
Pod documented
873 0 id => 'get_language_population',
874 field => 'territory',
875 table => 'language_population',
876 multi => 1,
877 }, @_ ) ); }
878  
879 0 ▶sub language_populations { return( shift->_fetch_all({
Subroutine language_populations: not called CC=1 SCAR=6.9
Pod documented
880 0 id => 'language_population',
881 table => 'language_population',
882 has_status => 'official_status',
883 }, @_ ) ); }
884  
885 5 ▶sub likely_subtag { return( shift->_fetch_one({
Subroutine likely_subtag: called CC=1 SCAR=0.0
Pod documented
886 5 id => 'get_likely_subtags',
887 field => 'locale',
888 table => 'likely_subtags',
889 }, @_ ) ); }
890  
891 0 ▶sub likely_subtags { return( shift->_fetch_all({
Subroutine likely_subtags: not called CC=1 SCAR=6.9
Pod documented
892 0 id => 'likely_subtags',
893 table => 'likely_subtags',
894 }, @_ ) ); }
895  
896 487 ▶sub locale { return( shift->_fetch_one({
Subroutine locale: called CC=1 SCAR=0.0
Pod documented
897 487 id => 'get_locale',
898 field => 'locale',
899 table => 'locales',
900 has_array => [qw( collations )],
901 }, @_ ) ); }
902  
903 0 ▶sub locales { return( shift->_fetch_all({
Subroutine locales: not called CC=1 SCAR=6.9
Pod documented
904 0 id => 'locales',
905 table => 'locales',
906 has_status => 1,
907 has_array => [qw( collations )],
908 }, @_ ) ); }
909  
910 1 ▶sub locale_l10n { return( shift->_fetch_one({
Subroutine locale_l10n: called CC=1 SCAR=0.0
Pod documented
911 1 id => 'get_locale_l10n',
912 field => 'locale_id',
913 table => 'locales_l10n',
914 requires => [qw( locale alt )],
915 default => { alt => undef },
916 }, @_ ) ); }
917  
918 3 ▶sub locales_l10n { return( shift->_fetch_all({
Subroutine locales_l10n: called CC=1 SCAR=0.0
Pod documented
919 3 id => 'locales_l10n',
920 table => 'locales_l10n',
921 by => [qw( locale locale_id alt )],
922 }, @_ ) ); }
923  
924 17 ▶sub locales_info { return( shift->_fetch_one({
Subroutine locales_info: called CC=1 SCAR=0.0
Pod documented
925 17 id => 'get_locales_info',
926 field => 'property',
927 table => 'locales_info',
928 requires => [qw( locale )],
929 }, @_ ) ); }
930  
931 0 ▶sub locales_infos { return( shift->_fetch_all({
Subroutine locales_infos: not called CC=1 SCAR=6.9
Pod documented
932 0 id => 'locales_info',
933 table => 'locales_info',
934 }, @_ ) ); }
935  
936 0 ▶sub locale_number_system { return( shift->_fetch_one({
Subroutine locale_number_system: not called CC=1 SCAR=6.9
Pod documented
937 0 id => 'get_locale_number_system',
938 field => 'locale',
939 table => 'locale_number_systems',
940 requires => [qw()],
941 }, @_ ) ); }
942  
943 0 ▶sub locale_number_systems { return( shift->_fetch_all({
Subroutine locale_number_systems: not called CC=1 SCAR=6.9
Pod documented
944 0 id => 'locale_number_systems',
945 table => 'locale_number_systems',
946 by => [qw( number_system native traditional finance )],
947 }, @_ ) ); }
948  
949 # <https://unicode.org/reports/tr35/tr35.html#Locale_Inheritance>
950 sub make_inheritance_tree
951 473 ▶{
Subroutine make_inheritance_tree: called CC=34 SCAR=56.8
Pod documented
952 473 my $self = shift( @_ );
953 473 ▶ my $locale = $self->_locale_object( shift( @_ ) ) ||
Condition50%1/2
$self->_locale_object(shift @_) || (return $self->pass_error)
l!l
4730
MC/DC0%0/1
$self->_locale_object(shift @_) || (return $self->pass_error)
$self->_locale_object(shift @_)
Truth table50%1/2
A
A= $self->_locale_object(shift @_)
Aresult
11
00
954 return( $self->pass_error );
955 473 ▶ $locale = $self->_locale_object( $locale->clone->base ) ||
Condition50%1/2
$self->_locale_object($locale->clone->base) || (return $self->pass_error)
l!l
4730
MC/DC0%0/1
$self->_locale_object($locale->clone->base) || (return $self->pass_error)
$self->_locale_object($locale->clone->base)
Truth table50%1/2
A
A= $self->_locale_object($locale->clone->base)
Aresult
11
00
956 return( $self->pass_error );
957 473 my $tree = ["$locale"];
958 473 my $ref;
959 473 ▶ if( ( $ref = $self->locale( locale => $locale ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->locale("locale", $locale) and $ref->{"parent"}) 8 465 473
Condition100%3/3
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
!ll&&!rl&&r
24638
MC/DC100%2/2
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
$ref = $self->locale("locale", $locale) $ref->{"parent"}
Truth table100%3/3
A and B
A= $ref = $self->locale("locale", $locale)B= $ref->{"parent"}
ABresult
0X0
100
111
960 $ref->{parent} )
961 {
962 8 ▶ my $tree2 = $self->make_inheritance_tree( $ref->{parent} ) || return( $self->pass_error );
Condition50%1/2
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
l!l
80
MC/DC0%0/1
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
$self->make_inheritance_tree($ref->{'parent'})
Truth table50%1/2
A
A= $self->make_inheritance_tree($ref->{'parent'})
Aresult
11
00
963 8 push( @$tree, @$tree2 );
964 8 return( $tree );
965 }
966  
967 # The locale has something like en-Latn-US, we need to save in the tree en-US
968 465 ▶ if( $locale->territory && ( $locale->script || $locale->variant ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($locale->territory and $locale->script || $locale->variant) 1 464 465
Condition83%5/6
$locale->territory and $locale->script || $locale->variant
!ll&&!rl&&r
454101
$locale->script or $locale->variant
l!l&&r!l&&!r
1010
MC/DC66%2/3
$locale->territory and $locale->script || $locale->variant
$locale->territory $locale->script $locale->variant
Truth table75%3/4
A and B or C
A= $locale->territoryB= $locale->scriptC= $locale->variant
ABCresult
0XX0
1000
11X1
1011
969 {
970 1 my $clone = $locale->clone;
971 1 $clone->script( undef );
972 1 $clone->variant( undef );
973 1 push( @$tree, "$clone" );
974 1 ▶ if( ( $ref = $self->locale( locale => $clone ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->locale("locale", $clone) and $ref->{"parent"}) 0 1 1
Condition33%1/3
$ref = $self->locale("locale", $clone) and $ref->{"parent"}
!ll&&!rl&&r
010
MC/DC0%0/2
$ref = $self->locale("locale", $clone) and $ref->{"parent"}
$ref = $self->locale("locale", $clone) $ref->{"parent"}
Truth table33%1/3
A and B
A= $ref = $self->locale("locale", $clone)B= $ref->{"parent"}
ABresult
0X0
100
111
975 $ref->{parent} )
976 {
977 0 ▶ my $tree2 = $self->make_inheritance_tree( $ref->{parent} ) || return( $self->pass_error );
Condition0%0/2
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
$self->make_inheritance_tree($ref->{'parent'})
Truth table0%0/2
A
A= $self->make_inheritance_tree($ref->{'parent'})
Aresult
11
00
978 0 push( @$tree, @$tree2 );
979 0 return( $tree );
980 }
981 }
982  
983 # "The default search chain is slighly different for multiple variants. In that case, the inheritance chain covers all combinations of variants, with longest number of variants first, and otherwise in alphabetical order."
984 # Check if there are more than one variants, in which case, we add each variation by removing one variant at each iteration
985 465 my $variants = $locale->variants;
986 465 ▶ if( scalar( @$variants ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$variants) 0 465 465
987 {
988 0 ▶ if( scalar( @$variants ) > 1 )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$variants > 1) 0 0 0
989 {
990 0 local $" = '-';
991 0 my $seen = { "@$variants" => 1 };
992 # We use permutation to produce all possible combinations
993 # Credits: <https://stackoverflow.com/questions/10299961/in-perl-how-can-i-generate-all-possible-combinations-of-a-list>
994 0 my $permute;
995 $permute = sub
996 0 ▶ {
Subroutine __ANON__: not called CC=4 SCAR=30.0
997 0 my( $list, $n ) = @_;
998 0 ▶ return( map( [$_], @$list ) ) if( $n <= 1 );
Branch: 1 branch
BranchTrueFalseTotal
if $n <= 1 0 0 0
999 0 my @comb;
1000 0 for my $i ( 0 .. $#$list )
1001 {
1002 0 my @rest = @$list;
1003 0 my $val = splice( @rest, $i, 1 );
1004 0 push( @comb, [$val, @$_] ) for( $permute->( \@rest, $n - 1 ) );
1005 }
1006 0 return( @comb );
1007 0 };
1008  
1009 0 ▶ while( scalar( @$variants ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$variants) 0 0 0
1010 {
1011 0 my @variations = $permute->( $variants, scalar( @$variants ) );
1012 0 foreach my $ref ( @variations )
1013 {
1014 0 ▶ if( scalar( keys( %$seen ) ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %$seen) 0 0 0
1015 {
1016 # We skip the default set of variants that have been tested at the start.
1017 0 ▶ if( exists( $seen->{ "@$ref" } ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$seen{join $", @$ref}) 0 0 0
1018 {
1019 0 delete( $seen->{ "@$ref" } );
1020 0 next;
1021 }
1022 }
1023 0 $locale->variant( "@$ref" );
1024 0 push( @$tree, "$locale" );
1025 }
1026 0 pop( @$variants );
1027 }
1028 }
1029  
1030 0 $locale->variant( undef );
1031 0 push( @$tree, "$locale" );
1032 0 ▶ if( ( $ref = $self->locale( locale => $locale ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->locale("locale", $locale) and $ref->{"parent"}) 0 0 0
Condition0%0/3
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
$ref = $self->locale("locale", $locale) $ref->{"parent"}
Truth table0%0/3
A and B
A= $ref = $self->locale("locale", $locale)B= $ref->{"parent"}
ABresult
0X0
100
111
1033 $ref->{parent} )
1034 {
1035 0 ▶ my $tree2 = $self->make_inheritance_tree( $ref->{parent} ) || return( $self->pass_error );
Condition0%0/2
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
$self->make_inheritance_tree($ref->{'parent'})
Truth table0%0/2
A
A= $self->make_inheritance_tree($ref->{'parent'})
Aresult
11
00
1036 0 push( @$tree, @$tree2 );
1037 0 return( $tree );
1038 }
1039 }
1040  
1041 465 ▶ if( $locale->territory )
Branch: 1 branch
BranchTrueFalseTotal
if ($locale->territory) 11 454 465
1042 {
1043 11 $locale->territory( undef );
1044 11 push( @$tree, "$locale" );
1045 11 ▶ if( ( $ref = $self->locale( locale => $locale ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->locale("locale", $locale) and $ref->{"parent"}) 0 11 11
Condition33%1/3
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
!ll&&!rl&&r
0110
MC/DC0%0/2
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
$ref = $self->locale("locale", $locale) $ref->{"parent"}
Truth table33%1/3
A and B
A= $ref = $self->locale("locale", $locale)B= $ref->{"parent"}
ABresult
0X0
100
111
1046 $ref->{parent} )
1047 {
1048 0 ▶ my $tree2 = $self->make_inheritance_tree( $ref->{parent} ) || return( $self->pass_error );
Condition0%0/2
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
$self->make_inheritance_tree($ref->{'parent'})
Truth table0%0/2
A
A= $self->make_inheritance_tree($ref->{'parent'})
Aresult
11
00
1049 0 push( @$tree, @$tree2 );
1050 0 return( $tree );
1051 }
1052 }
1053  
1054 465 ▶ if( $locale->script )
Branch: 1 branch
BranchTrueFalseTotal
if ($locale->script) 1 464 465
1055 {
1056 1 $locale->script( undef );
1057 1 push( @$tree, "$locale" );
1058 1 ▶ if( ( $ref = $self->locale( locale => $locale ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->locale("locale", $locale) and $ref->{"parent"}) 0 1 1
Condition33%1/3
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
!ll&&!rl&&r
010
MC/DC0%0/2
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
$ref = $self->locale("locale", $locale) $ref->{"parent"}
Truth table33%1/3
A and B
A= $ref = $self->locale("locale", $locale)B= $ref->{"parent"}
ABresult
0X0
100
111
1059 $ref->{parent} )
1060 {
1061 0 ▶ my $tree2 = $self->make_inheritance_tree( $ref->{parent} ) || return( $self->pass_error );
Condition0%0/2
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
$self->make_inheritance_tree($ref->{'parent'})
Truth table0%0/2
A
A= $self->make_inheritance_tree($ref->{'parent'})
Aresult
11
00
1062 0 push( @$tree, @$tree2 );
1063 0 return( $tree );
1064 }
1065 }
1066 # Make sure our last resort is not the same as our initial value
1067 # For example: fr -> fr
1068 465 ▶ if( !scalar( grep( $_ eq $locale, @$tree ) ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar grep(($_ eq $locale), @$tree)) 0 465 465
1069 {
1070 0 push( @$tree, "$locale" );
1071 0 ▶ if( ( $ref = $self->locale( locale => $locale ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->locale("locale", $locale) and $ref->{"parent"}) 0 0 0
Condition0%0/3
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ref = $self->locale("locale", $locale) and $ref->{"parent"}
$ref = $self->locale("locale", $locale) $ref->{"parent"}
Truth table0%0/3
A and B
A= $ref = $self->locale("locale", $locale)B= $ref->{"parent"}
ABresult
0X0
100
111
1072 $ref->{parent} )
1073 {
1074 0 ▶ my $tree2 = $self->make_inheritance_tree( $ref->{parent} ) || return( $self->pass_error );
Condition0%0/2
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->make_inheritance_tree($ref->{'parent'}) || (return $self->pass_error)
$self->make_inheritance_tree($ref->{'parent'})
Truth table0%0/2
A
A= $self->make_inheritance_tree($ref->{'parent'})
Aresult
11
00
1075 0 push( @$tree, @$tree2 );
1076 0 return( $tree );
1077 }
1078 }
1079 465 ▶ push( @$tree, 'und' ) unless( $tree->[-1] eq 'und' );
Branch: 1 branch
BranchTrueFalseTotal
unless $tree->[-1] eq "und" 460 5 465
1080 465 return( $tree );
1081 }
1082  
1083 2 ▶sub metazone { return( shift->_fetch_one({
Subroutine metazone: called CC=1 SCAR=0.0
Pod documented
1084 2 id => 'get_metazone',
1085 field => 'metazone',
1086 table => 'metazones',
1087 has_array => [qw( territories timezones )],
1088 }, @_ ) ); }
1089  
1090 0 ▶sub metazones { return( shift->_fetch_all({
Subroutine metazones: not called CC=1 SCAR=6.9
Pod documented
1091 0 id => 'metazones',
1092 table => 'metazones',
1093 by => [],
1094 has_array => [qw( territories timezones )],
1095 }, @_ ) ); }
1096  
1097 6 ▶sub metazone_names { return( shift->_fetch_one({
Subroutine metazone_names: called CC=1 SCAR=0.0
Pod documented
1098 6 id => 'get_metazone_names',
1099 field => 'metazone',
1100 table => 'metazones_names',
1101 requires => [qw( locale width )],
1102 default => { start => undef },
1103 }, @_ ) ); }
1104  
1105 0 ▶sub metazones_names { return( shift->_fetch_all({
Subroutine metazones_names: not called CC=1 SCAR=6.9
Pod documented
1106 0 id => 'metazones_names',
1107 table => 'metazones_names',
1108 by => [qw( locale metazone width )],
1109 }, @_ ) ); }
1110  
1111 # <https://unicode.org/reports/tr35/tr35.html#5.-canonicalizing-syntax>
1112 # <https://unicode.org/reports/tr35/tr35.html#4.-replacement>
1113 sub normalise
1114 12 ▶{
Subroutine normalise: called CC=75 SCAR=59.5
Pod documented
1115 12 my $self = shift( @_ );
1116 12 my $orig = shift( @_ );
1117 12 my $ref;
1118 12 ▶ unless( Scalar::Util::blessed( $orig ) &&
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($orig) and $orig->isa("Locale::Unicode")) 11 1 12
Condition66%2/3
builtin::blessed($orig) and $orig->isa("Locale::Unicode")
!ll&&!rl&&r
1101
MC/DC50%1/2
builtin::blessed($orig) and $orig->isa("Locale::Unicode")
builtin::blessed($orig) $orig->isa("Locale::Unicode")
Truth table66%2/3
A and B
A= builtin::blessed($orig)B= $orig->isa("Locale::Unicode")
ABresult
0X0
100
111
1119 $orig->isa( 'Locale::Unicode' ) )
1120 {
1121 11 my $backup = $orig;
1122 11 $orig = Locale::Unicode->new( "$orig" );
1123 11 ▶ if( !defined( $orig ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $orig) 0 11 11
1124 {
1125 0 ▶ if( ( $ref = $self->alias( alias => $backup, type => 'language' ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->alias('alias', $backup, 'type', 'language') and ref($ref->{'replacement'} // '') eq 'ARRAY' and scalar @{$ref->{'replacement'};}) { } 0 0 0
Condition0%0/7
$ref = $self->alias("alias", $backup, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
00
$ref = $self->alias("alias", $backup, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY"
!ll&&!rl&&r
000
$ref->{"replacement"} // ""
l!l
00
MC/DC0%0/2
$ref = $self->alias("alias", $backup, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
$ref = $self->alias("alias", $backup, "type", "language") $ref->{"replacement"}
Truth table0%0/3
A and B
A= $ref = $self->alias("alias", $backup, "type", "language")B= $ref->{"replacement"}
ABresult
0X0
100
111
1126 ref( $ref->{replacement} // '' ) eq 'ARRAY' &&
1127 0 scalar( @{$ref->{replacement}} ) )
1128 {
1129 0 ▶ my $locale = Locale::Unicode->new( $ref->{replacement}->[0] ) ||
Condition0%0/2
'Locale::Unicode'->new($ref->{'replacement'}[0]) || (return $self->pass_error('Locale::Unicode'->error))
l!l
00
MC/DC0%0/1
'Locale::Unicode'->new($ref->{'replacement'}[0]) || (return $self->pass_error('Locale::Unicode'->error))
'Locale::Unicode'->new($ref->{'replacement'}[0])
Truth table0%0/2
A
A= 'Locale::Unicode'->new($ref->{'replacement'}[0])
Aresult
11
00
1130 return( $self->pass_error( Locale::Unicode->error ) );
1131 0 return( $locale );
1132 }
1133 else
1134 {
1135 0 return( $self->pass_error( Locale::Unicode->error ) );
1136 }
1137 }
1138 }
1139 # canonical will create a clone
1140 # my $locale = $orig->canonical;
1141 12 my $locale = $orig;
1142  
1143 # <https://unicode.org/reports/tr35/tr35.html#BCP_47_Language_Tag_Conversion>
1144 # <https://unicode.org/reports/tr35/tr35.html#2.-alias-elements>
1145 # <https://unicode.org/reports/tr35/tr35.html#Unicode_Locale_Identifier_BCP_47_to_CLDR>
1146 12 ▶ if( my $privateuse = $locale->privateuse )
Branch: 5 branches
BranchTrueFalseTotal
if (my $privateuse = $locale->privateuse) { } 1 11 12
elsif (my $grandfathered = $locale->grandfathered) { } 1 10 11
elsif (not $locale->language_id) { } 0 10 10
elsif ($ref = $self->alias('alias', "$locale", 'type', 'language') and ref($ref->{'replacement'} // '') eq 'ARRAY' and scalar @{$ref->{'replacement'};}) { } 1 9 10
elsif ($ref = $self->alias('alias', $locale->language_extended, 'type', 'language') and ref($ref->{'replacement'} // '') eq 'ARRAY' and scalar @{$ref->{'replacement'};}) { } 4 10 14
1147 {
1148 1 $locale->private( $privateuse );
1149 1 $locale->language3( 'und' );
1150 }
1151 elsif( my $grandfathered = $locale->grandfathered )
1152 {
1153 1 ▶ if( ( $ref = $self->alias( alias => $grandfathered, type => 'language' ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->alias("alias", $grandfathered, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}) 1 0 1
Condition42%3/7
$ref = $self->alias("alias", $grandfathered, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
01
$ref = $self->alias("alias", $grandfathered, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY"
!ll&&!rl&&r
001
$ref->{"replacement"} // ""
l!l
10
MC/DC0%0/2
$ref = $self->alias("alias", $grandfathered, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
$ref = $self->alias("alias", $grandfathered, "type", "language") $ref->{"replacement"}
Truth table33%1/3
A and B
A= $ref = $self->alias("alias", $grandfathered, "type", "language")B= $ref->{"replacement"}
ABresult
0X0
100
111
1154 ref( $ref->{replacement} // '' ) eq 'ARRAY' &&
1155 1 scalar( @{$ref->{replacement}} ) )
1156 {
1157 1 my $tmp = Locale::Unicode->new( $ref->{replacement}->[0] );
1158 1 $tmp = $tmp->canonical;
1159 # Ensure the aias value we received is, itself, normalised.
1160 1 ▶ $tmp = $self->normalise( $tmp ) || return( $self->pass_error );
Condition50%1/2
$self->normalise($tmp) || (return $self->pass_error)
l!l
10
MC/DC0%0/1
$self->normalise($tmp) || (return $self->pass_error)
$self->normalise($tmp)
Truth table50%1/2
A
A= $self->normalise($tmp)
Aresult
11
00
1161 1 $locale->merge( $tmp );
1162 # Do not overwrite it
1163 1 ▶ $locale->private( $grandfathered ) unless( $locale->private );
Branch: 1 branch
BranchTrueFalseTotal
unless $locale->private 0 1 1
1164 }
1165 }
1166 elsif( !$locale->language_id )
1167 {
1168 0 $locale->language3( 'und' );
1169 }
1170 ▶ elsif( ( $ref = $self->alias( alias => "$locale", type => 'language' ) ) &&
Condition71%5/7
$ref = $self->alias("alias", "$locale", "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
91
$ref = $self->alias("alias", "$locale", "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY"
!ll&&!rl&&r
901
$ref->{"replacement"} // ""
l!l
10
MC/DC50%1/2
$ref = $self->alias("alias", "$locale", "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
$ref = $self->alias("alias", "$locale", "type", "language") $ref->{"replacement"}
Truth table66%2/3
A and B
A= $ref = $self->alias("alias", "$locale", "type", "language")B= $ref->{"replacement"}
ABresult
0X0
100
111
1171 ref( $ref->{replacement} // '' ) eq 'ARRAY' &&
1172 1 scalar( @{$ref->{replacement}} ) )
1173 {
1174 1 my $repl = $ref->{replacement}->[0];
1175 1 ▶ while( $ref = $self->alias( alias => $repl, type => 'language' ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->alias("alias", $repl, "type", "language") && ref($ref->{"replacement"} // "") eq "ARRAY" && scalar @{$ref->{"replacement"};}) 0 1 1
Condition28%2/7
$self->alias('alias', $repl, 'type', 'language') && ref($ref->{'replacement'} // '') eq 'ARRAY' && scalar @{$ref->{'replacement'};}
!ll
10
$self->alias("alias", $repl, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY"
!ll&&!rl&&r
100
$ref->{"replacement"} // ""
l!l
00
MC/DC0%0/2
$self->alias('alias', $repl, 'type', 'language') && ref($ref->{'replacement'} // '') eq 'ARRAY' && scalar @{$ref->{'replacement'};}
$self->alias("alias", $repl, "type", "language") $ref->{"replacement"}
Truth table33%1/3
A and B
A= $self->alias("alias", $repl, "type", "language")B= $ref->{"replacement"}
ABresult
0X0
100
111
1176 ref( $ref->{replacement} // '' ) eq 'ARRAY' &&
1177 0 scalar( @{$ref->{replacement}} ) )
1178 {
1179 0 $repl = $ref->{replacement}->[0];
1180 }
1181  
1182 1 my $tmp = Locale::Unicode->new( $repl );
1183 1 $locale->base( $tmp->base );
1184 }
1185 ▶ elsif( ( $ref = $self->alias( alias => $locale->language_extended, type => 'language' ) ) &&
Condition71%5/7
$ref = $self->alias("alias", $locale->language_extended, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
54
$ref = $self->alias("alias", $locale->language_extended, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY"
!ll&&!rl&&r
504
$ref->{"replacement"} // ""
l!l
40
MC/DC50%1/2
$ref = $self->alias("alias", $locale->language_extended, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
$ref = $self->alias("alias", $locale->language_extended, "type", "language") $ref->{"replacement"}
Truth table66%2/3
A and B
A= $ref = $self->alias("alias", $locale->language_extended, "type", "language")B= $ref->{"replacement"}
ABresult
0X0
100
111
1186 ref( $ref->{replacement} // '' ) eq 'ARRAY' &&
1187 4 scalar( @{$ref->{replacement}} ) )
1188 {
1189 4 my $repl = $ref->{replacement}->[0];
1190 4 ▶ while( $ref = $self->alias( alias => $repl, type => 'language' ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->alias("alias", $repl, "type", "language") && ref($ref->{"replacement"} // "") eq "ARRAY" && scalar @{$ref->{"replacement"};}) 0 4 4
Condition28%2/7
$self->alias('alias', $repl, 'type', 'language') && ref($ref->{'replacement'} // '') eq 'ARRAY' && scalar @{$ref->{'replacement'};}
!ll
40
$self->alias("alias", $repl, "type", "language") and ref($ref->{"replacement"} // "") eq "ARRAY"
!ll&&!rl&&r
400
$ref->{"replacement"} // ""
l!l
00
MC/DC0%0/2
$self->alias('alias', $repl, 'type', 'language') && ref($ref->{'replacement'} // '') eq 'ARRAY' && scalar @{$ref->{'replacement'};}
$self->alias("alias", $repl, "type", "language") $ref->{"replacement"}
Truth table33%1/3
A and B
A= $self->alias("alias", $repl, "type", "language")B= $ref->{"replacement"}
ABresult
0X0
100
111
1191 ref( $ref->{replacement} // '' ) eq 'ARRAY' &&
1192 0 scalar( @{$ref->{replacement}} ) )
1193 {
1194 0 $repl = $ref->{replacement}->[0];
1195 }
1196 4 my $tmp = Locale::Unicode->new( $repl );
1197 4 $locale->language_id( undef );
1198 4 $locale->extended( undef );
1199 4 $locale->merge( $tmp );
1200 }
1201  
1202 # As per the LDML specifications:
1203 # "If the field = territory, and the replacement.field has more than one value, then look up the most likely territory for the base language code (and script, if there is one). If that likely territory is in the list of replacements, use it. Otherwise, use the first territory in the list."
1204 # <https://unicode.org/reports/tr35/tr35.html#territory-exception>
1205 12 ▶ if( $locale->territory &&
Branch: 1 branch
BranchTrueFalseTotal
if ($locale->territory and $ref = $self->alias("alias", $locale->territory, "type", "territory") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}) 3 9 12
Condition80%8/10
$locale->territory and $ref = $self->alias("alias", $locale->territory, "type", "territory") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
93
$locale->territory and $ref = $self->alias("alias", $locale->territory, "type", "territory") and ref($ref->{"replacement"} // "") eq "ARRAY"
!ll&&!rl&&r
903
$locale->territory and $ref = $self->alias("alias", $locale->territory, "type", "territory")
!ll&&!rl&&r
633
$ref->{"replacement"} // ""
l!l
30
MC/DC66%2/3
$locale->territory and $ref = $self->alias("alias", $locale->territory, "type", "territory") and ref($ref->{"replacement"} // "") eq "ARRAY" and scalar @{$ref->{"replacement"};}
$locale->territory $ref = $self->alias("alias", $locale->territory, "type", "territory") $ref->{"replacement"}
Truth table75%3/4
A and B and C
A= $locale->territoryB= $ref = $self->alias("alias", $locale->territory, "type", "territory")C= $ref->{"replacement"}
ABCresult
0XX0
10X0
1100
1111
1206 ( $ref = $self->alias( alias => $locale->territory, type => 'territory' ) ) &&
1207 ref( $ref->{replacement} // '' ) eq 'ARRAY' &&
1208 3 scalar( @{$ref->{replacement}} ) )
1209 {
1210 3 ▶ if( scalar( @{$ref->{replacement}} ) > 1 )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$ref->{'replacement'};} > 1) { } 2 1 3
1211 {
1212 2 ▶ my $tree = $self->make_inheritance_tree( $locale ) ||
Condition50%1/2
$self->make_inheritance_tree($locale) || (return $self->pass_error)
l!l
20
MC/DC0%0/1
$self->make_inheritance_tree($locale) || (return $self->pass_error)
$self->make_inheritance_tree($locale)
Truth table50%1/2
A
A= $self->make_inheritance_tree($locale)
Aresult
11
00
1213 return( $self->pass_error );
1214 2 my $likely;
1215 2 foreach my $loc ( @$tree )
1216 {
1217 4 $likely = $self->likely_subtag( locale => $loc );
1218 4 ▶ last if( $likely && $likely->{target} );
Branch: 1 branch
BranchTrueFalseTotal
if $likely and $likely->{"target"} 2 2 4
Condition66%2/3
$likely and $likely->{"target"}
!ll&&!rl&&r
202
MC/DC50%1/2
$likely and $likely->{"target"}
$likely $likely->{"target"}
Truth table66%2/3
A and B
A= $likelyB= $likely->{"target"}
ABresult
0X0
100
111
1219 }
1220  
1221 2 ▶ if( defined( $likely ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $likely) { } 2 0 2
1222 {
1223 2 ▶ my $tmp = Locale::Unicode->new( $likely->{target} ) ||
Condition50%1/2
'Locale::Unicode'->new($likely->{'target'}) || (return $self->pass_error('Locale::Unicode'->error))
l!l
20
MC/DC0%0/1
'Locale::Unicode'->new($likely->{'target'}) || (return $self->pass_error('Locale::Unicode'->error))
'Locale::Unicode'->new($likely->{'target'})
Truth table50%1/2
A
A= 'Locale::Unicode'->new($likely->{'target'})
Aresult
11
00
1224 return( $self->pass_error( Locale::Unicode->error ) );
1225 2 my $cc = $tmp->territory;
1226 2 ▶ if( !$cc )
Branch: 1 branch
BranchTrueFalseTotal
unless ($cc) 0 2 2
1227 {
1228 0 die( "It seems the Locale::Unicode::Data is corrupted as I could get a likely subtag for ${locale}, but the target '${tmp}' does not seem to contain a territory, which is impossible." );
1229 }
1230 2 ▶ if( scalar( grep( /^${cc}$/i, @{$ref->{replacement}} ) ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar grep(/^$cc$/i, @{$$ref{'replacement'};})) { } 2 0 2
1231 {
1232 2 $locale->territory( $cc );
1233 }
1234 else
1235 {
1236 0 $locale->territory( $ref->{replacement}->[0] );
1237 }
1238 }
1239 else
1240 {
1241 0 $locale->territory( $ref->{replacement}->[0] );
1242 }
1243 }
1244 else
1245 {
1246 1 $locale->territory( $ref->{replacement}->[0] );
1247 }
1248 }
1249  
1250 12 ▶ if( $locale->variant )
Branch: 1 branch
BranchTrueFalseTotal
if ($locale->variant) 1 11 12
1251 {
1252 1 my $variants = [map{ lc( $_ ) } @{$locale->variants}];
1253 1 my $permute;
1254 $permute = sub
1255 14 ▶ {
Subroutine __ANON__: called CC=4 SCAR=13.9
1256 14 my( $list, $n ) = @_;
1257 14 ▶ return( map( [$_], @$list ) ) if( $n <= 1 );
Branch: 1 branch
BranchTrueFalseTotal
if $n <= 1 9 5 14
1258 5 my @comb;
1259 5 for my $i ( 0 .. $#$list )
1260 {
1261 12 my @rest = @$list;
1262 12 my $val = splice( @rest, $i, 1 );
1263 12 push( @comb, [$val, @$_] ) for( $permute->( \@rest, $n - 1 ) );
1264 }
1265 5 return( @comb );
1266 1 };
1267  
1268 1 my $seen = {};
1269 1 my $found = 0;
1270 1 local $" = '-';
1271 1 my $len = scalar( @$variants );
1272 1 ▶ VARIANTS: while( $len > 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($len > 0) 2 0 2
1273 {
1274 2 ▶ $seen->{ $variants->[0] }++ if( scalar( @$variants ) );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$variants 2 0 2
1275 2 my @variations = $permute->( $variants, $len );
1276 2 foreach my $combo ( @variations )
1277 {
1278 10 ▶ if( ( $ref = $self->alias( alias => "und-@$combo", type => 'language' ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->alias("alias", "und-@$combo", "type", "language") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}) 1 9 10
Condition80%4/5
$ref = $self->alias("alias", "und-@$combo", "type", "language") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
91
$ref = $self->alias("alias", "und-@$combo", "type", "language") and ref $ref->{"replacement"} eq "ARRAY"
!ll&&!rl&&r
901
MC/DC50%1/2
$ref = $self->alias("alias", "und-@$combo", "type", "language") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}
$ref = $self->alias("alias", "und-@$combo", "type", "language") ref $ref->{"replacement"} eq "ARRAY"
Truth table66%2/3
A and B
A= $ref = $self->alias("alias", "und-@$combo", "type", "language")B= ref $ref->{"replacement"} eq "ARRAY"
ABresult
0X0
100
111
1279 ref( $ref->{replacement} ) eq 'ARRAY' &&
1280 1 scalar( @{$ref->{replacement}} ) )
1281 {
1282 1 ▶ MATCH: for( my $i = 0; $i < scalar( @$combo ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$combo) 2 1 3
1283 {
1284 2 ▶ for( my $j = 0; $j < scalar( @$variants ); $j++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($j < scalar @$variants) 4 0 4
1285 {
1286 4 ▶ if( $combo->[$i] eq $variants->[$j] )
Branch: 1 branch
BranchTrueFalseTotal
if ($combo->[$i] eq $variants->[$j]) 2 2 4
1287 {
1288 2 splice( @$variants, $j, 1 );
1289 2 next MATCH;
1290 }
1291 }
1292 }
1293 # Set the new updated variants
1294 1 ▶ if( scalar( @$variants ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$variants) { } 1 0 1
1295 {
1296 1 $locale->variant( "@$variants" );
1297 }
1298 else
1299 {
1300 0 $locale->variant( undef );
1301 }
1302 1 my $tmp = Locale::Unicode->new( $ref->{replacement}->[0] );
1303 # language ID 'und' is just a dummy one used. However, if it is anything else, we need to keep it.
1304 1 ▶ $tmp->language_id( undef ) if( $tmp->language_id eq 'und' );
Branch: 1 branch
BranchTrueFalseTotal
if $tmp->language_id eq "und" 1 0 1
1305 1 $locale->merge( $tmp );
1306 1 $locale->variant( join( '-', sort( @{$locale->variants} ) ) );
1307 1 $found++;
1308 1 last VARIANTS;
1309 }
1310 }
1311 # pop( @$variants );
1312 1 $len--;
1313 }
1314 1 ▶ unless( $found )
Branch: 1 branch
BranchTrueFalseTotal
unless ($found) 0 1 1
1315 {
1316 0 foreach my $variant ( @{$locale->variants} )
1317 {
1318 0 ▶ next if( exists( $seen->{ $variant } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $seen->{$variant} 0 0 0
1319 0 ▶ if( ( $ref = $self->alias( alias => 'und-' . $variant, type => 'language' ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->alias("alias", 'und-' . $variant, "type", "language") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}) 0 0 0
Condition0%0/5
$ref = $self->alias("alias", 'und-' . $variant, "type", "language") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
00
$ref = $self->alias("alias", 'und-' . $variant, "type", "language") and ref $ref->{"replacement"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$ref = $self->alias("alias", 'und-' . $variant, "type", "language") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}
$ref = $self->alias("alias", 'und-' . $variant, "type", "language") ref $ref->{"replacement"} eq "ARRAY"
Truth table0%0/3
A and B
A= $ref = $self->alias("alias", 'und-' . $variant, "type", "language")B= ref $ref->{"replacement"} eq "ARRAY"
ABresult
0X0
100
111
1320 ref( $ref->{replacement} ) eq 'ARRAY' &&
1321 0 scalar( @{$ref->{replacement}} ) )
1322 {
1323 0 my $tmp = Locale::Unicode->new( $ref->{replacement}->[0] );
1324 0 $tmp->language_id( undef );
1325 0 $locale->merge( $tmp );
1326 0 $found++;
1327 0 last;
1328 }
1329 }
1330 }
1331 1 ▶ unless( $found )
Branch: 1 branch
BranchTrueFalseTotal
unless ($found) 0 1 1
1332 {
1333 0 foreach my $variant ( @{$locale->variants} )
1334 {
1335 0 ▶ if( ( $ref = $self->alias( alias => $variant, type => 'variant' ) ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ref = $self->alias("alias", $variant, "type", "variant") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}) 0 0 0
Condition0%0/5
$ref = $self->alias("alias", $variant, "type", "variant") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
00
$ref = $self->alias("alias", $variant, "type", "variant") and ref $ref->{"replacement"} eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$ref = $self->alias("alias", $variant, "type", "variant") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}
$ref = $self->alias("alias", $variant, "type", "variant") ref $ref->{"replacement"} eq "ARRAY"
Truth table0%0/3
A and B
A= $ref = $self->alias("alias", $variant, "type", "variant")B= ref $ref->{"replacement"} eq "ARRAY"
ABresult
0X0
100
111
1336 ref( $ref->{replacement} ) eq 'ARRAY' &&
1337 0 scalar( @{$ref->{replacement}} ) )
1338 {
1339 0 $locale->variant( $ref->{replacement}->[0] );
1340 0 $found++;
1341 0 last;
1342 }
1343 }
1344 }
1345 }
1346  
1347 12 my $script;
1348 12 ▶ if( ( $script = $locale->script ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($script = $locale->script and $ref = $self->alias("alias", $script, "type", "script") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}) 0 12 12
Condition50%4/8
$script = $locale->script and $ref = $self->alias("alias", $script, "type", "script") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}
!ll
120
$script = $locale->script and $ref = $self->alias("alias", $script, "type", "script") and ref $ref->{"replacement"} eq "ARRAY"
!ll&&!rl&&r
1200
$script = $locale->script and $ref = $self->alias("alias", $script, "type", "script")
!ll&&!rl&&r
930
MC/DC0%0/3
$script = $locale->script and $ref = $self->alias("alias", $script, "type", "script") and ref $ref->{"replacement"} eq "ARRAY" and scalar @{$ref->{"replacement"};}
$script = $locale->script $ref = $self->alias("alias", $script, "type", "script") ref $ref->{"replacement"} eq "ARRAY"
Truth table50%2/4
A and B and C
A= $script = $locale->scriptB= $ref = $self->alias("alias", $script, "type", "script")C= ref $ref->{"replacement"} eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
1349 ( $ref = $self->alias( alias => $script, type => 'script' ) ) &&
1350 ref( $ref->{replacement} ) eq 'ARRAY' &&
1351 0 scalar( @{$ref->{replacement}} ) )
1352 {
1353 0 $locale->script( $ref->{replacement}->[0] );
1354 }
1355  
1356 12 return( $locale );
1357 }
1358  
1359 {
1360 7 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
1361 7 *normalize = \&normalise;
1362 }
1363  
1364 1 ▶sub number_format_l10n { return( shift->_fetch_one({
Subroutine number_format_l10n: called CC=1 SCAR=0.0
Pod documented
1365 1 id => 'get_number_format_l10n',
1366 field => 'format_id',
1367 table => 'number_formats_l10n',
1368 requires => [qw( locale number_system number_type format_length format_type alt count )],
1369 default => { alt => undef, count => undef },
1370 }, @_ ) ); }
1371  
1372 2 ▶sub number_formats_l10n { return( shift->_fetch_all({
Subroutine number_formats_l10n: called CC=1 SCAR=0.0
Pod documented
1373 2 id => 'number_formats_l10n',
1374 table => 'number_formats_l10n',
1375 by => [qw( locale number_system number_type format_length format_type alt count )],
1376 }, @_ ) ); }
1377  
1378 1 ▶sub number_symbol_l10n { return( shift->_fetch_one({
Subroutine number_symbol_l10n: called CC=1 SCAR=0.0
Pod documented
1379 1 id => 'getnumber_symbol_l10n',
1380 field => 'property',
1381 table => 'number_symbols_l10n',
1382 requires => [qw( locale number_system alt )],
1383 default => { alt => undef },
1384 }, @_ ) ); }
1385  
1386 2 ▶sub number_symbols_l10n { return( shift->_fetch_all({
Subroutine number_symbols_l10n: called CC=1 SCAR=0.0
Pod documented
1387 2 id => 'number_symbols_l10n',
1388 table => 'number_symbols_l10n',
1389 by => [qw( locale number_system alt )],
1390 }, @_ ) ); }
1391  
1392 1 ▶sub number_system { return( shift->_fetch_one({
Subroutine number_system: called CC=1 SCAR=0.0
Pod documented
1393 1 id => 'get_number_system',
1394 field => 'number_system',
1395 table => 'number_systems',
1396 has_array => [qw( digits )],
1397 }, @_ ) ); }
1398  
1399 0 ▶sub number_systems { return( shift->_fetch_all({
Subroutine number_systems: not called CC=1 SCAR=6.9
Pod documented
1400 0 id => 'number_systems',
1401 table => 'number_systems',
1402 has_array => [qw( digits )],
1403 }, @_ ) ); }
1404  
1405 1 ▶sub number_system_l10n { return( shift->_fetch_one({
Subroutine number_system_l10n: called CC=1 SCAR=0.0
Pod documented
1406 1 id => 'getnumber_system_l10n',
1407 field => 'number_system',
1408 table => 'number_systems_l10n',
1409 requires => [qw( locale alt )],
1410 default => { alt => undef },
1411 }, @_ ) ); }
1412  
1413 0 ▶sub number_systems_l10n { return( shift->_fetch_all({
Subroutine number_systems_l10n: not called CC=1 SCAR=6.9
Pod documented
1414 0 id => 'number_systems_l10n',
1415 table => 'number_systems_l10n',
1416 by => [qw( locale number_system alt )],
1417 }, @_ ) ); }
1418  
1419 sub pass_error
1420 0 ▶{
Subroutine pass_error: not called CC=37 SCAR=71.8
Pod undocumented
1421 0 my $self = shift( @_ );
1422 0 ▶ my $pack = ref( $self ) || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
1423 0 my $opts = {};
1424 0 my( $err, $class, $code );
1425 7 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1426 0 ▶ if( scalar( @_ ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) 0 0 0
1427 {
1428 # Either an hash defining a new error and this will be passed along to error(); or
1429 # an hash with a single property: { class => 'Some::ExceptionClass' }
1430 0 ▶ if( scalar( @_ ) == 1 && ref( $_[0] ) eq 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ == 1 and ref $_[0] eq 'HASH') { } 0 0 0
Condition0%0/3
scalar @_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @_ == 1 and ref $_[0] eq "HASH"
scalar @_ == 1 ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= scalar @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
1431 {
1432 0 $opts = $_[0];
1433 }
1434 else
1435 {
1436 0 ▶ if( scalar( @_ ) > 1 && ref( $_[-1] ) eq 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ > 1 and ref $_[-1] eq "HASH") 0 0 0
Condition0%0/3
scalar @_ > 1 and ref $_[-1] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @_ > 1 and ref $_[-1] eq "HASH"
scalar @_ > 1 ref $_[-1] eq "HASH"
Truth table0%0/3
A and B
A= scalar @_ > 1B= ref $_[-1] eq "HASH"
ABresult
0X0
100
111
1437 {
1438 0 $opts = pop( @_ );
1439 }
1440 0 $err = $_[0];
1441 }
1442 }
1443 0 ▶ $err = $opts->{error} if( !defined( $err ) && CORE::exists( $opts->{error} ) && defined( $opts->{error} ) && CORE::length( $opts->{error} ) );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $err and exists $opts->{"error"} and defined $opts->{"error"} and length $opts->{"error"} 0 0 0
Condition0%0/9
not defined $err and exists $opts->{"error"} and defined $opts->{"error"} and length $opts->{"error"}
!ll&&!rl&&r
000
not defined $err and exists $opts->{"error"} and defined $opts->{"error"}
!ll&&!rl&&r
000
not defined $err and exists $opts->{"error"}
!ll&&!rl&&r
000
MC/DC0%0/4
not defined $err and exists $opts->{"error"} and defined $opts->{"error"} and length $opts->{"error"}
not defined $err exists $opts->{"error"} defined $opts->{"error"} length $opts->{"error"}
Truth table0%0/5
not(A) and B and C and D
A= not defined $errB= exists $opts->{"error"}C= defined $opts->{"error"}D= length $opts->{"error"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1444 # We set $class only if the hash provided is a one-element hash and not an error-defining hash
1445 0 ▶ $class = $opts->{class} if( CORE::exists( $opts->{class} ) && defined( $opts->{class} ) && CORE::length( $opts->{class} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts->{"class"} and defined $opts->{"class"} and length $opts->{"class"} 0 0 0
Condition0%0/6
exists $opts->{"class"} and defined $opts->{"class"} and length $opts->{"class"}
!ll&&!rl&&r
000
exists $opts->{"class"} and defined $opts->{"class"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $opts->{"class"} and defined $opts->{"class"} and length $opts->{"class"}
exists $opts->{"class"} defined $opts->{"class"} length $opts->{"class"}
Truth table0%0/4
A and B and C
A= exists $opts->{"class"}B= defined $opts->{"class"}C= length $opts->{"class"}
ABCresult
0XX0
10X0
1100
1111
1446 0 ▶ $code = $opts->{code} if( CORE::exists( $opts->{code} ) && defined( $opts->{code} ) && CORE::length( $opts->{code} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts->{"code"} and defined $opts->{"code"} and length $opts->{"code"} 0 0 0
Condition0%0/6
exists $opts->{"code"} and defined $opts->{"code"} and length $opts->{"code"}
!ll&&!rl&&r
000
exists $opts->{"code"} and defined $opts->{"code"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $opts->{"code"} and defined $opts->{"code"} and length $opts->{"code"}
exists $opts->{"code"} defined $opts->{"code"} length $opts->{"code"}
Truth table0%0/4
A and B and C
A= exists $opts->{"code"}B= defined $opts->{"code"}C= length $opts->{"code"}
ABCresult
0XX0
10X0
1100
1111
1447  
1448 # called with no argument, most likely from the same class to pass on an error
1449 # set up earlier by another method; or
1450 # with an hash containing just one argument class => 'Some::ExceptionClass'
1451 0 ▶ if( !defined( $err ) && ( !scalar( @_ ) || defined( $class ) ) )
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $err and !scalar(@_) || defined $class) { } 0 0 0
elsif (defined $err and builtin::blessed($err) and scalar @_ == 1 || scalar @_ == 2 && defined $class) { } 0 0 0
Condition0%0/6
not defined $err and !scalar(@_) || defined $class
!ll&&!rl&&r
000
not scalar @_ or defined $class
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $err and !scalar(@_) || defined $class
not defined $err not scalar @_ defined $class
Truth table0%0/4
not(A) and not(B) or C
A= not defined $errB= not scalar @_C= defined $class
ABCresult
0XX0
1000
11X1
1011
1452 {
1453 # $error is a previous erro robject
1454 0 ▶ my $error = ref( $self ) ? $self->{error} : length( ${ $pack . '::ERROR' } ) ? ${ $pack . '::ERROR' } : undef;
Branch: 2 branches
BranchTrueFalseTotal
ref $self ? : 0 0 0
length ${$pack . '::ERROR';} ? : 0 0 0
1455 0 ▶ if( !defined( $error ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $error) { } 0 0 0
1456 {
1457 0 warn( "No error object provided and no previous error set either! It seems the previous method call returned a simple undef" );
1458 }
1459 else
1460 {
1461 0 ▶ $err = ( defined( $class ) ? bless( $error => $class ) : $error );
Branch: 1 branch
BranchTrueFalseTotal
defined $class ? : 0 0 0
1462 0 ▶ $err->code( $code ) if( defined( $code ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $code 0 0 0
1463 }
1464 }
1465 ▶ elsif( defined( $err ) &&
Condition0%0/12
defined $err and builtin::blessed($err) and scalar @_ == 1 || scalar @_ == 2 && defined $class
!ll&&!rl&&r
000
defined $err and builtin::blessed($err)
!ll&&!rl&&r
000
scalar @_ == 1 or scalar @_ == 2 and defined $class
l!l&&r!l&&!r
000
scalar @_ == 2 and defined $class
!ll&&!rl&&r
000
MC/DC0%0/5
defined $err and builtin::blessed($err) and scalar @_ == 1 || scalar @_ == 2 && defined $class
defined $err builtin::blessed($err) scalar @_ == 1 scalar @_ == 2 defined $class
Truth table0%0/6
A and B and C or D and E
A= defined $errB= builtin::blessed($err)C= scalar @_ == 1D= scalar @_ == 2E= defined $class
ABCDEresult
0XXXX0
10XXX0
1100X0
110100
111XX1
110111
1466 Scalar::Util::blessed( $err ) &&
1467 ( scalar( @_ ) == 1 ||
1468 ( scalar( @_ ) == 2 && defined( $class ) )
1469 ) )
1470 {
1471 0 ▶ $self->{error} = ${ $pack . '::ERROR' } = ( defined( $class ) ? bless( $err => $class ) : $err );
Branch: 1 branch
BranchTrueFalseTotal
defined $class ? : 0 0 0
1472 0 ▶ $self->{error}->code( $code ) if( defined( $code ) && $self->{error}->can( 'code' ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $code and $self->{"error"}->can("code") 0 0 0
Condition0%0/3
defined $code and $self->{"error"}->can("code")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $code and $self->{"error"}->can("code")
defined $code $self->{"error"}->can("code")
Truth table0%0/3
A and B
A= defined $codeB= $self->{"error"}->can("code")
ABresult
0X0
100
111
1473  
1474 0 ▶ if( $self->{fatal} || ( defined( ${"${class}\::FATAL_EXCEPTIONS"} ) && ${"${class}\::FATAL_EXCEPTIONS"} ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"fatal"} or defined ${"${class}::FATAL_EXCEPTIONS";} and ${"${class}::FATAL_EXCEPTIONS";}) 0 0 0
Condition0%0/6
$self->{"fatal"} or defined ${"${class}::FATAL_EXCEPTIONS";} and ${"${class}::FATAL_EXCEPTIONS";}
l!l&&r!l&&!r
000
defined ${"${class}::FATAL_EXCEPTIONS";} and ${"${class}::FATAL_EXCEPTIONS";}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"fatal"} or defined ${"${class}::FATAL_EXCEPTIONS";} and ${"${class}::FATAL_EXCEPTIONS";}
$self->{"fatal"} defined ${"${class}::FATAL_EXCEPTIONS";} ${"${class}::FATAL_EXCEPTIONS";}
Truth table0%0/4
A or B and C
A= $self->{"fatal"}B= defined ${"${class}::FATAL_EXCEPTIONS";}C= ${"${class}::FATAL_EXCEPTIONS";}
ABCresult
1XX1
0111
00X0
0100
1475 {
1476 0 die( $self->{error} );
1477 }
1478 }
1479 # If the error provided is not an object, we call error to create one
1480 else
1481 {
1482 0 return( $self->error( @_ ) );
1483 }
1484  
1485 0 ▶ if( want( 'OBJECT' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (want("OBJECT")) 0 0 0
1486 {
1487 0 rreturn( Locale::Unicode::Data::NullObject->new );
1488 }
1489 0 return;
1490 }
1491  
1492 1 ▶sub person_name_default { return( shift->_fetch_one({
Subroutine person_name_default: called CC=1 SCAR=0.0
Pod documented
1493 1 id => 'get_person_name_default',
1494 field => 'locale',
1495 table => 'person_name_defaults',
1496 }, @_ ) ); }
1497  
1498 0 ▶sub person_name_defaults { return( shift->_fetch_all({
Subroutine person_name_defaults: not called CC=1 SCAR=6.9
Pod documented
1499 0 id => 'person_name_defaults',
1500 table => 'person_name_defaults',
1501 }, @_ ) ); }
1502  
1503 # These methods implement key steps of the CLDR person name formatting algorithm
1504 # described in UTS #35 Part 8. Insert them alongside PART 1 (in alphabetical order
1505 # within the person_name_* group).
1506  
1507 # person_name_derive_order( formatting_locale => 'ja', name_locale => 'ko' )
1508 # -> returns 'givenFirst' or 'surnameFirst', by consulting person_name_order_locales
1509 # for the formatting locale, matching against the name locale's base language
1510 # and the 'und' catch-all.
1511 #
1512 # This implements step 3 of the CLDR "Derive the name order" algorithm, full lookup
1513 # (base language + 'und') with the full parent-locale chain traversal, which requires
1514 # the parentLocales supplemental data. For the full algorithm see UTS #35 Part 8 section
1515 # "Derive the name order".
1516 # The default when no match is found is 'givenFirst', as specified by CLDR.
1517 #
1518 # NOTE: The caller should pass a preferredOrder from the PersonName object when
1519 # available (step 2 of the algorithm), as that takes precedence over this method.
1520 sub person_name_derive_order
1521 7 ▶{
Subroutine person_name_derive_order: called CC=17 SCAR=30.7
Pod documented
1522 7 my $self = shift( @_ );
1523 7 my %args = @_;
1524 my $fmt_locale = $args{formatting_locale} ||
1525 7 ▶ return( $self->error( "Missing required argument 'formatting_locale'" ) );
Condition50%1/2
$args{'formatting_locale'} || (return $self->error(q[Missing required argument 'formatting_locale']))
l!l
70
MC/DC0%0/1
$args{'formatting_locale'} || (return $self->error(q[Missing required argument 'formatting_locale']))
$args{'formatting_locale'}
Truth table50%1/2
A
A= $args{'formatting_locale'}
Aresult
11
00
1526 my $name_locale = $args{name_locale} ||
1527 7 ▶ return( $self->error( "Missing required argument 'name_locale'" ) );
Condition50%1/2
$args{'name_locale'} || (return $self->error(q[Missing required argument 'name_locale']))
l!l
70
MC/DC0%0/1
$args{'name_locale'} || (return $self->error(q[Missing required argument 'name_locale']))
$args{'name_locale'}
Truth table50%1/2
A
A= $args{'name_locale'}
Aresult
11
00
1528 7 ▶ my $fmt_tree = $self->make_inheritance_tree( $fmt_locale ) ||
Condition50%1/2
$self->make_inheritance_tree($fmt_locale) || (return $self->pass_error)
l!l
70
MC/DC0%0/1
$self->make_inheritance_tree($fmt_locale) || (return $self->pass_error)
$self->make_inheritance_tree($fmt_locale)
Truth table50%1/2
A
A= $self->make_inheritance_tree($fmt_locale)
Aresult
11
00
1529 return( $self->pass_error );
1530 7 ▶ my $name_tree = $self->make_inheritance_tree( $name_locale ) ||
Condition50%1/2
$self->make_inheritance_tree($name_locale) || (return $self->pass_error)
l!l
70
MC/DC0%0/1
$self->make_inheritance_tree($name_locale) || (return $self->pass_error)
$self->make_inheritance_tree($name_locale)
Truth table50%1/2
A
A= $self->make_inheritance_tree($name_locale)
Aresult
11
00
1531 return( $self->pass_error );
1532 7 my $rules = {};
1533  
1534 7 foreach my $locale ( @$fmt_tree )
1535 {
1536 16 my $refs = $self->person_name_order_locales(
1537 locale => $locale,
1538 );
1539 16 ▶ return( $self->pass_error ) if( !defined( $refs ) && $self->error );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $refs and $self->error 0 16 16
Condition33%1/3
not defined $refs and $self->error
!ll&&!rl&&r
1600
MC/DC0%0/2
not defined $refs and $self->error
not defined $refs $self->error
Truth table33%1/3
not(A) and B
A= not defined $refsB= $self->error
ABresult
0X0
100
111
1540 16 ▶ next unless( ref( $refs ) eq 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $refs eq "ARRAY" 0 16 16
1541  
1542 16 foreach my $ref ( @$refs )
1543 {
1544 94 my $key = lc( $ref->{name_locale} );
1545 94 ▶ next if( exists( $rules->{ $key } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $rules->{$key} 39 55 94
1546 55 $rules->{ $key } = $ref->{name_order};
1547 }
1548 }
1549  
1550 7 foreach my $name ( @$name_tree )
1551 {
1552 7 ▶ my $locale = $self->_locale_object( $name ) ||
Condition50%1/2
$self->_locale_object($name) || (return $self->pass_error)
l!l
70
MC/DC0%0/1
$self->_locale_object($name) || (return $self->pass_error)
$self->_locale_object($name)
Truth table50%1/2
A
A= $self->_locale_object($name)
Aresult
11
00
1553 return( $self->pass_error );
1554 7 my @lookup = ( lc( "$locale" ) );
1555  
1556 7 my $language = $locale->language_id;
1557 7 ▶ if( defined( $language ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $language and lc $language ne "und") 7 0 7
Condition33%1/3
defined $language and lc $language ne "und"
!ll&&!rl&&r
007
MC/DC0%0/2
defined $language and lc $language ne "und"
defined $language lc $language ne "und"
Truth table33%1/3
A and B
A= defined $languageB= lc $language ne "und"
ABresult
0X0
100
111
1558 lc( $language ) ne 'und' )
1559 {
1560 7 my $und = $locale->clone;
1561 7 $und->language_id( 'und' );
1562 7 push( @lookup, lc( "$und" ) );
1563 }
1564  
1565 7 foreach my $candidate ( @lookup )
1566 {
1567 return( $rules->{ $candidate } )
1568 9 ▶ if( exists( $rules->{ $candidate } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $rules->{$candidate} 7 2 9
1569 }
1570 }
1571  
1572 # CLDR default when neither the name locale nor 'und' is found
1573 0 return( 'givenFirst' );
1574 }
1575  
1576 4 ▶sub person_name_format { return( shift->_fetch_one({
Subroutine person_name_format: called CC=1 SCAR=0.0
Pod documented
1577 4 id => 'get_person_name_format',
1578 field => 'name_order',
1579 table => 'person_name_formats',
1580 requires => [qw( locale name_length name_usage name_formality alt )],
1581 default => { alt => undef },
1582 }, @_ ) ); }
1583  
1584 4 ▶sub person_name_formats { return( shift->_fetch_all({
Subroutine person_name_formats: called CC=1 SCAR=0.0
Pod documented
1585 4 id => 'person_name_formats',
1586 table => 'person_name_formats',
1587 by => [qw( locale name_index name_order name_length name_usage name_formality alt )],
1588 order => 'name_index, pers_name_fmt_id',
1589 }, @_ ) ); }
1590  
1591 3 ▶sub person_name_initial_pattern { return( shift->_fetch_one({
Subroutine person_name_initial_pattern: called CC=1 SCAR=0.0
Pod documented
1592 3 id => 'get_person_name_initial_pattern',
1593 field => 'pattern_type',
1594 table => 'person_name_initial_patterns',
1595 requires => [qw( locale )],
1596 }, @_ ) ); }
1597  
1598 1 ▶sub person_name_initial_patterns { return( shift->_fetch_all({
Subroutine person_name_initial_patterns: called CC=1 SCAR=0.0
Pod documented
1599 1 id => 'person_name_initial_patterns',
1600 table => 'person_name_initial_patterns',
1601 by => [qw( locale )],
1602 order => 'pattern_type',
1603 }, @_ ) ); }
1604  
1605 4 ▶sub person_name_order_locale { return( shift->_fetch_one({
Subroutine person_name_order_locale: called CC=1 SCAR=0.0
Pod documented
1606 4 id => 'get_person_name_order_locale',
1607 field => 'name_locale',
1608 table => 'person_name_order_locales',
1609 requires => [qw( locale )],
1610 }, @_ ) ); }
1611  
1612 18 ▶sub person_name_order_locales { return( shift->_fetch_all({
Subroutine person_name_order_locales: called CC=1 SCAR=0.0
Pod documented
1613 18 id => 'person_name_order_locales',
1614 table => 'person_name_order_locales',
1615 by => [qw( locale name_order )],
1616 order => 'name_locale',
1617 }, @_ ) ); }
1618  
1619 6 ▶sub person_name_sample { return( shift->_fetch_one({
Subroutine person_name_sample: called CC=1 SCAR=0.0
Pod documented
1620 6 id => 'get_person_name_sample',
1621 field => 'field_type',
1622 table => 'person_name_samples',
1623 requires => [qw( locale sample_type )],
1624 }, @_ ) ); }
1625  
1626 2 ▶sub person_name_samples { return( shift->_fetch_all({
Subroutine person_name_samples: called CC=1 SCAR=0.0
Pod documented
1627 2 id => 'person_name_samples',
1628 table => 'person_name_samples',
1629 by => [qw( locale sample_type )],
1630 order => 'pers_name_samp_id',
1631 }, @_ ) ); }
1632  
1633 # person_name_space_replacement( formatting_locale => 'ja', name_locale => 'de' )
1634 # -> returns the correct space replacement string for this locale pair, fetched from
1635 # locales_info (keys person_name_native_space / person_name_foreign_space), applying
1636 # CLDR defaults when no explicit value is stored.
1637 #
1638 # Per the spec (Setting the spaceReplacement):
1639 # 1. foreignSpaceReplacement default is SPACE (" ").
1640 # 2. nativeSpaceReplacement default is SPACE (" ").
1641 # 3. If formatter base language matches name base language -> nativeSpaceReplacement,
1642 # else -> foreignSpaceReplacement.
1643 # 4. Two base languages "match" when identical, or both in {ja, zh, yue}.
1644 #
1645 # NOTE: This method compares base languages only (the first subtag of the BCP 47 locale
1646 # tag). The caller is responsible for deriving the correct base languages from the full
1647 # locale identifiers, including script switching as described in the spec section
1648 # "Switch the formatting locale if necessary".
1649 sub person_name_space_replacement
1650 9 ▶{
Subroutine person_name_space_replacement: called CC=15 SCAR=29.1
Pod documented
1651 9 my $self = shift( @_ );
1652 9 my %args = @_;
1653 9 ▶ unless( exists( $args{formatting_locale} ) &&
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"formatting_locale"} and defined $args{"formatting_locale"}) 0 9 9
Condition33%1/3
exists $args{"formatting_locale"} and defined $args{"formatting_locale"}
!ll&&!rl&&r
009
MC/DC0%0/2
exists $args{"formatting_locale"} and defined $args{"formatting_locale"}
exists $args{"formatting_locale"} defined $args{"formatting_locale"}
Truth table33%1/3
A and B
A= exists $args{"formatting_locale"}B= defined $args{"formatting_locale"}
ABresult
0X0
100
111
1654 defined( $args{formatting_locale} ) )
1655 {
1656 0 return( $self->error( "Missing required argument 'formatting_locale'" ) );
1657 }
1658 9 ▶ unless( exists( $args{name_locale} ) &&
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"name_locale"} and defined $args{"name_locale"}) 0 9 9
Condition33%1/3
exists $args{"name_locale"} and defined $args{"name_locale"}
!ll&&!rl&&r
009
MC/DC0%0/2
exists $args{"name_locale"} and defined $args{"name_locale"}
exists $args{"name_locale"} defined $args{"name_locale"}
Truth table33%1/3
A and B
A= exists $args{"name_locale"}B= defined $args{"name_locale"}
ABresult
0X0
100
111
1659 defined( $args{name_locale} ) )
1660 {
1661 0 return( $self->error( "Missing required argument 'name_locale'" ) );
1662 }
1663 9 ▶ my $fmt_locale = Locale::Unicode->new( $args{formatting_locale} ) ||
Condition50%1/2
'Locale::Unicode'->new($args{'formatting_locale'}) || (return $self->pass_error('Locale::Unicode'->error))
l!l
90
MC/DC0%0/1
'Locale::Unicode'->new($args{'formatting_locale'}) || (return $self->pass_error('Locale::Unicode'->error))
'Locale::Unicode'->new($args{'formatting_locale'})
Truth table50%1/2
A
A= 'Locale::Unicode'->new($args{'formatting_locale'})
Aresult
11
00
1664 return( $self->pass_error( Locale::Unicode->error ) );
1665 9 ▶ my $name_locale = Locale::Unicode->new( $args{name_locale} ) ||
Condition50%1/2
'Locale::Unicode'->new($args{'name_locale'}) || (return $self->pass_error('Locale::Unicode'->error))
l!l
90
MC/DC0%0/1
'Locale::Unicode'->new($args{'name_locale'}) || (return $self->pass_error('Locale::Unicode'->error))
'Locale::Unicode'->new($args{'name_locale'})
Truth table50%1/2
A
A= 'Locale::Unicode'->new($args{'name_locale'})
Aresult
11
00
1666 return( $self->pass_error( Locale::Unicode->error ) );
1667 # A locale is composed, possibly, of a language-script-territory.
1668 # Locale::Unicode->language_id() returns either the two-character or three-character language portion.
1669 9 my $fmt_lang = $fmt_locale->language_id;
1670 9 my $name_lang = $name_locale->language_id;
1671 9 $fmt_lang = lc( $fmt_lang );
1672 9 $name_lang = lc( $name_lang );
1673 9 my %cjk_group = map{ $_ => 1 } qw( ja zh yue );
1674 my $languages_match =
1675 ( $fmt_lang eq $name_lang ) ||
1676 9 ▶ ( exists( $cjk_group{ $fmt_lang } ) && exists( $cjk_group{ $name_lang } ) );
Condition100%6/6
$fmt_lang eq $name_lang || exists $cjk_group{$fmt_lang} && exists $cjk_group{$name_lang}
l!l&&r!l&&!r
324
exists $cjk_group{$fmt_lang} and exists $cjk_group{$name_lang}
!ll&&!rl&&r
132
MC/DC100%3/3
$fmt_lang eq $name_lang || exists $cjk_group{$fmt_lang} && exists $cjk_group{$name_lang}
$fmt_lang eq $name_lang exists $cjk_group{$fmt_lang} exists $cjk_group{$name_lang}
Truth table100%4/4
A || B and C
A= $fmt_lang eq $name_langB= exists $cjk_group{$fmt_lang}C= exists $cjk_group{$name_lang}
ABCresult
1XX1
0111
00X0
0100
1677 9 ▶ my $prop_key = $languages_match
Branch: 1 branch
BranchTrueFalseTotal
$languages_match ? : 5 4 9
1678 ? 'person_name_native_space'
1679 : 'person_name_foreign_space';
1680 9 ▶ my $tree = $self->make_inheritance_tree( $fmt_locale ) ||
Condition50%1/2
$self->make_inheritance_tree($fmt_locale) || (return $self->pass_error)
l!l
90
MC/DC0%0/1
$self->make_inheritance_tree($fmt_locale) || (return $self->pass_error)
$self->make_inheritance_tree($fmt_locale)
Truth table50%1/2
A
A= $self->make_inheritance_tree($fmt_locale)
Aresult
11
00
1681 return( $self->pass_error );
1682  
1683 9 foreach my $locale ( @$tree )
1684 {
1685 12 my $ref = $self->locales_info(
1686 locale => $locale,
1687 property => $prop_key,
1688 );
1689  
1690 12 ▶ if( defined( $ref ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ref and scalar keys %$ref and defined $ref->{"value"}) 9 3 12
Condition80%4/5
defined $ref and scalar keys %$ref and defined $ref->{"value"}
!ll&&!rl&&r
309
defined $ref and scalar keys %$ref
!ll
39
MC/DC50%1/2
defined $ref and scalar keys %$ref and defined $ref->{"value"}
defined $ref defined $ref->{"value"}
Truth table66%2/3
A and B
A= defined $refB= defined $ref->{"value"}
ABresult
0X0
100
111
1691 scalar( keys( %$ref ) ) &&
1692 defined( $ref->{value} ) )
1693 {
1694 9 return( $ref->{value} );
1695 }
1696 }
1697  
1698 0 return( ' ' );
1699 }
1700  
1701 # NOTE: plural rules for 222 locales based on the Unicode CDR rules set out in supplemental/plurals.xml
1702 # This is for the method plural_count()
1703 my $plural_rules =
1704 {
1705 # 1: other
1706 # bm bo dz hnj id ig ii in ja jbo jv jw kde kea km ko lkt lo ms my nqo osa root sah ses sg su th to tpi vi wo yo yue zh
1707 8 ▶ bm => { other => sub { 1 } },
Subroutine __ANON__: called CC=1 SCAR=0.0
1708 # The other locales in this group are aliased
1709  
1710 # 2: one, other
1711 # am as bn doi fa gu hi kn pcm zu
1712 am =>
1713 {
1714 6 ▶ one => sub { $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 1 1 5 6
1715 4 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1716 },
1717 # The other locales in this group are aliased
1718  
1719 # ff hy kab
1720 ff =>
1721 {
1722 0 ▶ one => sub { $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 1 0 0 0
1723 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1724 },
1725 # The other locales in this group are aliased
1726  
1727 # ast de en et fi fy gl ia io ji lij nl sc sv sw ur yi
1728 ast =>
1729 {
1730 4 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 1 3 4
1731 3 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1732 },
1733 # The other locales in this group are aliased
1734  
1735 # si (Sinhala):
1736 si =>
1737 {
1738 one => sub
1739 7 ▶ {
Subroutine __ANON__: called CC=4 SCAR=13.9
1740 7 ▶ $_[0] == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 1 or int $_[0] == 0 and $_[0] != 0 4 3 7
Condition88%8/9
$_[0] == 0 || $_[0] == 1 || int $_[0] == 0 && $_[0] != 0
l!l&&r!l&&!r
421
$_[0] == 0 or $_[0] == 1
l!l&&r!l&&!r
133
int $_[0] == 0 and $_[0] != 0
!ll&&!rl&&r
102
MC/DC75%3/4
$_[0] == 0 || $_[0] == 1 || int $_[0] == 0 && $_[0] != 0
$_[0] == 0 $_[0] == 1 int $_[0] == 0 $_[0] != 0
Truth table80%4/5
A or B || C and D
A= $_[0] == 0B= $_[0] == 1C= int $_[0] == 0D= $_[0] != 0
ABCDresult
1XXX1
01XX1
00111
000X0
00100
1741 $_[0] == 1 ||
1742 # For decimals where the integer part is 0
1743 ( int( $_[0] ) == 0 && $_[0] != 0 )
1744 },
1745 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1746 },
1747 # ak bho csw guw ln mg nso pa ti wa
1748 ak =>
1749 {
1750 0 ▶ one => sub { $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 1 0 0 0
1751 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1752 },
1753 # The other locales in this group are aliased
1754  
1755 # tzm
1756 tzm =>
1757 {
1758 one => sub
1759 6 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.1
1760 6 ▶ $_[0] == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 1 or $_[0] >= 11 and $_[0] <= 99 and int $_[0] == $_[0] 2 4 6
Condition91%11/12
$_[0] == 0 || $_[0] == 1 || $_[0] >= 11 && $_[0] <= 99 && int $_[0] == $_[0]
l!l&&r!l&&!r
222
$_[0] == 0 or $_[0] == 1
l!l&&r!l&&!r
114
$_[0] >= 11 and $_[0] <= 99 and int $_[0] == $_[0]
!ll&&!rl&&r
202
$_[0] >= 11 and $_[0] <= 99
!ll&&!rl&&r
112
MC/DC80%4/5
$_[0] == 0 || $_[0] == 1 || $_[0] >= 11 && $_[0] <= 99 && int $_[0] == $_[0]
$_[0] == 0 $_[0] == 1 $_[0] >= 11 $_[0] <= 99 int $_[0] == $_[0]
Truth table83%5/6
A or B || C and D and E
A= $_[0] == 0B= $_[0] == 1C= $_[0] >= 11D= $_[0] <= 99E= int $_[0] == $_[0]
ABCDEresult
1XXXX1
01XXX1
001111
000XX0
0010X0
001100
1761 $_[0] == 1 ||
1762 (
1763 $_[0] >= 11 &&
1764 $_[0] <= 99 &&
1765 int( $_[0] ) == $_[0]
1766 )
1767 },
1768 2 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1769 },
1770 # af an asa az bal bem bez bg brx ce cgg chr ckb dv ee el eo eu fo fur gsw ha haw hu jgo jmc ka kaj kcg kk kkj kl ks ksb ku ky lb lg mas mgo ml mn mr nah nb nd ne nn nnh no nr ny nyn om or os pap ps rm rof rwk saq sd sdh seh sn so sq ss ssy st syr ta te teo tig tk tn tr ts ug uz ve vo vun wae xh xog
1771 af =>
1772 {
1773 0 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 0 0 0
1774 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1775 },
1776 # The other locales in this group are aliased
1777  
1778 # da
1779 da =>
1780 {
1781 one => sub
1782 4 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
1783 4 ▶ $_[0] == 1 ||
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 or int $_[0] != $_[0] and int $_[0] == 0 1 3 4
Condition83%5/6
$_[0] == 1 || int $_[0] != $_[0] && int $_[0] == 0
l!l&&r!l&&!r
112
int $_[0] != $_[0] and int $_[0] == 0
!ll&&!rl&&r
201
MC/DC66%2/3
$_[0] == 1 || int $_[0] != $_[0] && int $_[0] == 0
$_[0] == 1 int $_[0] != $_[0] int $_[0] == 0
Truth table75%3/4
A || B and C
A= $_[0] == 1B= int $_[0] != $_[0]C= int $_[0] == 0
ABCresult
1XX1
0111
00X0
0100
1784 (
1785 int( $_[0] ) != $_[0] &&
1786 int( $_[0] ) == 0
1787 )
1788 },
1789 2 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1790 },
1791 # is: Icelandic
1792 is =>
1793 {
1794 one => sub
1795 6 ▶ {
Subroutine __ANON__: called CC=7 SCAR=19.7
1796 6 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11 or int $_[0] != $_[0] and $_[0] < "1.1" 2 4 6
Condition83%15/18
int $_[0] == $_[0] && ($_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11) || int $_[0] != $_[0] && $_[0] < 1.1
l!l&&r!l&&!r
213
int $_[0] == $_[0] and $_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11
!ll&&!rl&&r
222
$_[0] % 10 == 1 and $_[0] % 100 != 11 or int($_[0] * 10) % 10 == 1 and int($_[0] * 100) % 100 != 11
l!l&&r!l&&!r
202
$_[0] % 10 == 1 and $_[0] % 100 != 11
!ll&&!rl&&r
112
int($_[0] * 10) % 10 == 1 and int($_[0] * 100) % 100 != 11
!ll&&!rl&&r
200
int $_[0] != $_[0] and $_[0] < "1.1"
!ll&&!rl&&r
211
MC/DC57%4/7
int $_[0] == $_[0] && ($_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11) || int $_[0] != $_[0] && $_[0] < 1.1
int $_[0] == $_[0] $_[0] % 10 == 1 $_[0] % 100 != 11 int($_[0] * 10) % 10 == 1 int($_[0] * 100) % 100 != 11 int $_[0] != $_[0] $_[0] < "1.1"
Truth table27%5/18
A and B and C or D and E || F and G
A= int $_[0] == $_[0]B= $_[0] % 10 == 1C= $_[0] % 100 != 11D= int($_[0] * 10) % 10 == 1E= int($_[0] * 100) % 100 != 11F= int $_[0] != $_[0]G= $_[0] < "1.1"
ABCDEFGresult
111XXXX1
10X11XX1
11011XX1
0XXXX111
10X0X111
10X10111
1100X111
11010111
0XXXX0X0
0XXXX100
10X0X0X0
10X0X100
10X100X0
10X10100
1100X0X0
1100X100
110100X0
11010100
1797 (
1798 (
1799 $_[0] % 10 == 1 &&
1800 $_[0] % 100 != 11
1801 )
1802 ||
1803 (
1804 int( $_[0] * 10 ) % 10 == 1 &&
1805 int( $_[0] * 100 ) % 100 != 11
1806 )
1807 )
1808 ||
1809 # Handling decimals
1810 (
1811 int( $_[0] ) != $_[0] &&
1812 $_[0] < 1.1
1813 )
1814 },
1815 3 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1816 },
1817 # mk: Macedonian
1818 mk =>
1819 {
1820 one => sub
1821 6 ▶ {
Subroutine __ANON__: called CC=7 SCAR=19.7
1822 6 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11 or int $_[0] != $_[0] and $_[0] < "1.1" 2 4 6
Condition83%15/18
int $_[0] == $_[0] && ($_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11) || int $_[0] != $_[0] && $_[0] < 1.1
l!l&&r!l&&!r
213
int $_[0] == $_[0] and $_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11
!ll&&!rl&&r
222
$_[0] % 10 == 1 and $_[0] % 100 != 11 or int($_[0] * 10) % 10 == 1 and int($_[0] * 100) % 100 != 11
l!l&&r!l&&!r
202
$_[0] % 10 == 1 and $_[0] % 100 != 11
!ll&&!rl&&r
112
int($_[0] * 10) % 10 == 1 and int($_[0] * 100) % 100 != 11
!ll&&!rl&&r
200
int $_[0] != $_[0] and $_[0] < "1.1"
!ll&&!rl&&r
211
MC/DC57%4/7
int $_[0] == $_[0] && ($_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11) || int $_[0] != $_[0] && $_[0] < 1.1
int $_[0] == $_[0] $_[0] % 10 == 1 $_[0] % 100 != 11 int($_[0] * 10) % 10 == 1 int($_[0] * 100) % 100 != 11 int $_[0] != $_[0] $_[0] < "1.1"
Truth table27%5/18
A and B and C or D and E || F and G
A= int $_[0] == $_[0]B= $_[0] % 10 == 1C= $_[0] % 100 != 11D= int($_[0] * 10) % 10 == 1E= int($_[0] * 100) % 100 != 11F= int $_[0] != $_[0]G= $_[0] < "1.1"
ABCDEFGresult
111XXXX1
10X11XX1
11011XX1
0XXXX111
10X0X111
10X10111
1100X111
11010111
0XXXX0X0
0XXXX100
10X0X0X0
10X0X100
10X100X0
10X10100
1100X0X0
1100X100
110100X0
11010100
1823 (
1824 (
1825 $_[0] % 10 == 1 &&
1826 $_[0] % 100 != 11
1827 )
1828 ||
1829 (
1830 int( $_[0] * 10 ) % 10 == 1 &&
1831 int( $_[0] * 100 ) % 100 != 11
1832 )
1833 )
1834 ||
1835 # Handling decimals
1836 (
1837 int( $_[0] ) != $_[0] &&
1838 $_[0] < 1.1
1839 )
1840 },
1841 3 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1842 },
1843 # ceb fil tl
1844 ceb =>
1845 {
1846 one => sub
1847 11 ▶ {
Subroutine __ANON__: called CC=11 SCAR=24.0
1848 11 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] == 1 || $_[0] == 2 || $_[0] == 3 || $_[0] % 10 != 4 && $_[0] % 10 != 6 && $_[0] % 10 != 9 or int $_[0] != $_[0] and int($_[0] * 10) % 10 != 4 and int($_[0] * 10) % 10 != 6 and int($_[0] * 10) % 10 != 9 6 5 11
Condition93%28/30
int $_[0] == $_[0] && ($_[0] == 1 || $_[0] == 2 || $_[0] == 3 || $_[0] % 10 != 4 && $_[0] % 10 != 6 && $_[0] % 10 != 9) || int $_[0] != $_[0] && int($_[0] * 10) % 10 != 4 && int($_[0] * 10) % 10 != 6 && int($_[0] * 10) % 10 != 9
l!l&&r!l&&!r
614
int $_[0] == $_[0] and $_[0] == 1 || $_[0] == 2 || $_[0] == 3 || $_[0] % 10 != 4 && $_[0] % 10 != 6 && $_[0] % 10 != 9
!ll&&!rl&&r
236
$_[0] == 1 or $_[0] == 2 or $_[0] == 3 or $_[0] % 10 != 4 and $_[0] % 10 != 6 and $_[0] % 10 != 9
l!l&&r!l&&!r
333
$_[0] == 1 or $_[0] == 2 or $_[0] == 3
l!l&&r!l&&!r
216
$_[0] == 1 or $_[0] == 2
l!l&&r!l&&!r
117
$_[0] % 10 != 4 and $_[0] % 10 != 6 and $_[0] % 10 != 9
!ll&&!rl&&r
213
$_[0] % 10 != 4 and $_[0] % 10 != 6
!ll&&!rl&&r
114
int $_[0] != $_[0] and int($_[0] * 10) % 10 != 4 and int($_[0] * 10) % 10 != 6 and int($_[0] * 10) % 10 != 9
!ll&&!rl&&r
401
int $_[0] != $_[0] and int($_[0] * 10) % 10 != 4 and int($_[0] * 10) % 10 != 6
!ll&&!rl&&r
401
int $_[0] != $_[0] and int($_[0] * 10) % 10 != 4
!ll&&!rl&&r
311
MC/DC72%8/11
int $_[0] == $_[0] && ($_[0] == 1 || $_[0] == 2 || $_[0] == 3 || $_[0] % 10 != 4 && $_[0] % 10 != 6 && $_[0] % 10 != 9) || int $_[0] != $_[0] && int($_[0] * 10) % 10 != 4 && int($_[0] * 10) % 10 != 6 && int($_[0] * 10) % 10 != 9
int $_[0] == $_[0] $_[0] == 1 $_[0] == 2 $_[0] == 3 $_[0] % 10 != 4 $_[0] % 10 != 6 $_[0] % 10 != 9 int $_[0] != $_[0] int($_[0] * 10) % 10 != 4 int($_[0] * 10) % 10 != 6 int($_[0] * 10) % 10 != 9
Truth table37%9/24
A and B or C or D or E and F and G || H and I and J and K
A= int $_[0] == $_[0]B= $_[0] == 1C= $_[0] == 2D= $_[0] == 3E= $_[0] % 10 != 4F= $_[0] % 10 != 6G= $_[0] % 10 != 9H= int $_[0] != $_[0]I= int($_[0] * 10) % 10 != 4J= int($_[0] * 10) % 10 != 6K= int($_[0] * 10) % 10 != 9
ABCDEFGHIJKresult
11XXXXXXXXX1
101XXXXXXXX1
1001XXXXXXX1
1000111XXXX1
0XXXXXX11111
10000XX11111
100010X11111
100011011111
0XXXXXX0XXX0
0XXXXXX10XX0
0XXXXXX110X0
0XXXXXX11100
10000XX0XXX0
10000XX10XX0
10000XX110X0
10000XX11100
100010X0XXX0
100010X10XX0
100010X110X0
100010X11100
10001100XXX0
100011010XX0
1000110110X0
100011011100
1849 (
1850 (
1851 $_[0] == 1 ||
1852 $_[0] == 2 ||
1853 $_[0] == 3
1854 )
1855 ||
1856 (
1857 $_[0] % 10 != 4 &&
1858 $_[0] % 10 != 6 &&
1859 $_[0] % 10 != 9
1860 )
1861 )
1862 ||
1863 (
1864 int( $_[0] ) != $_[0] &&
1865 int( $_[0] * 10 ) % 10 != 4 &&
1866 int( $_[0] * 10 ) % 10 != 6 &&
1867 int( $_[0] * 10 ) % 10 != 9
1868 )
1869 },
1870 4 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1871 },
1872 # The other locales in this group are aliased
1873  
1874 # 3: zero, one, other
1875 # lv (Latvian) prg
1876 lv =>
1877 {
1878 zero => sub
1879 10 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.1
1880 # Check for very small numbers, including 0 and close to zero
1881 # Slightly larger threshold to catch 0.01 and 0.001
1882 10 ▶ abs( $_[0] ) < 0.011
Branch: 1 branch
BranchTrueFalseTotal
abs $_[0] < "0.011" or int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 100 >= 11 && $_[0] % 100 <= 19 4 6 10
Condition100%12/12
abs $_[0] < 0.011 || int $_[0] == $_[0] && ($_[0] % 10 == 0 || $_[0] % 100 >= 11 && $_[0] % 100 <= 19)
l!l&&r!l&&!r
424
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 100 >= 11 && $_[0] % 100 <= 19
!ll&&!rl&&r
222
$_[0] % 10 == 0 or $_[0] % 100 >= 11 and $_[0] % 100 <= 19
l!l&&r!l&&!r
112
$_[0] % 100 >= 11 and $_[0] % 100 <= 19
!ll&&!rl&&r
111
MC/DC100%5/5
abs $_[0] < 0.011 || int $_[0] == $_[0] && ($_[0] % 10 == 0 || $_[0] % 100 >= 11 && $_[0] % 100 <= 19)
abs $_[0] < 0.011 int $_[0] == $_[0] $_[0] % 10 == 0 $_[0] % 100 >= 11 $_[0] % 100 <= 19
Truth table100%6/6
A || B and C or D and E
A= abs $_[0] < 0.011B= int $_[0] == $_[0]C= $_[0] % 10 == 0D= $_[0] % 100 >= 11E= $_[0] % 100 <= 19
ABCDEresult
1XXXX1
011XX1
010111
00XXX0
0100X0
010100
1883 ||
1884 # Include integers
1885 (
1886 int( $_[0] ) == $_[0] &&
1887 (
1888 $_[0] % 10 == 0 ||
1889 (
1890 $_[0] % 100 >= 11 &&
1891 $_[0] % 100 <= 19
1892 )
1893 )
1894 )
1895 },
1896 one => sub
1897 4 ▶ {
Subroutine __ANON__: called CC=5 SCAR=18.9
1898 (
1899 4 ▶ $_[0] % 10 == 1 &&
Branch: 1 branch
BranchTrueFalseTotal
$_[0] % 10 == 1 and $_[0] % 100 != 11 or int $_[0] != $_[0] and $_[0] > "0.01" and $_[0] < "1.1" 2 2 4
Condition50%6/12
$_[0] % 10 == 1 && $_[0] % 100 != 11 || int $_[0] != $_[0] && $_[0] > 0.01 && $_[0] < 1.1
l!l&&r!l&&!r
220
$_[0] % 10 == 1 and $_[0] % 100 != 11
!ll&&!rl&&r
202
int $_[0] != $_[0] and $_[0] > "0.01" and $_[0] < "1.1"
!ll&&!rl&&r
002
int $_[0] != $_[0] and $_[0] > "0.01"
!ll&&!rl&&r
002
MC/DC0%0/5
$_[0] % 10 == 1 && $_[0] % 100 != 11 || int $_[0] != $_[0] && $_[0] > 0.01 && $_[0] < 1.1
$_[0] % 10 == 1 $_[0] % 100 != 11 int $_[0] != $_[0] $_[0] > "0.01" $_[0] < "1.1"
Truth table22%2/9
A and B || C and D and E
A= $_[0] % 10 == 1B= $_[0] % 100 != 11C= int $_[0] != $_[0]D= $_[0] > "0.01"E= $_[0] < "1.1"
ABCDEresult
11XXX1
0X1111
101111
0X0XX0
0X10X0
0X1100
100XX0
1010X0
101100
1900 $_[0] % 100 != 11
1901 )
1902 ||
1903 # Handle decimals for 'one', excluding numbers very close to zero
1904 (
1905 int( $_[0] ) != $_[0] &&
1906 # Exclude 0.01 explicitly
1907 $_[0] > 0.01 &&
1908 $_[0] < 1.1
1909 )
1910 },
1911 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1912 },
1913 # The other locales in this group are aliased
1914  
1915 # lag
1916 lag =>
1917 {
1918 4 ▶ zero => sub { $_[0] == 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1919 one => sub
1920 3 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
1921 3 ▶ $_[0] == 1 ||
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 or int $_[0] == 0 and int $_[0] != $_[0] 1 2 3
Condition83%5/6
$_[0] == 1 || int $_[0] == 0 && int $_[0] != $_[0]
l!l&&r!l&&!r
111
int $_[0] == 0 and int $_[0] != $_[0]
!ll&&!rl&&r
101
MC/DC66%2/3
$_[0] == 1 || int $_[0] == 0 && int $_[0] != $_[0]
$_[0] == 1 int $_[0] == 0 int $_[0] != $_[0]
Truth table75%3/4
A || B and C
A= $_[0] == 1B= int $_[0] == 0C= int $_[0] != $_[0]
ABCresult
1XX1
0111
00X0
0100
1922 (
1923 int( $_[0] ) == 0 &&
1924 int( $_[0] ) != $_[0]
1925 )
1926 },
1927 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1928 },
1929 # blo
1930 blo =>
1931 {
1932 3 ▶ zero => sub { $_[0] == 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1933 2 ▶ one => sub { $_[0] == 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1934 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1935 },
1936 # ksh
1937 ksh =>
1938 {
1939 0 ▶ zero => sub { $_[0] == 0 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1940 0 ▶ one => sub { $_[0] == 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1941 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1942 },
1943  
1944 # 3: one, two, other
1945 # he iw
1946 he =>
1947 {
1948 one => sub
1949 5 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.5
1950 (
1951 5 ▶ $_[0] == 1 &&
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] or int $_[0] != $_[0] and $_[0] > 0 and $_[0] < 2 1 4 5
Condition75%9/12
$_[0] == 1 && int $_[0] == $_[0] || int $_[0] != $_[0] && $_[0] > 0 && $_[0] < 2
l!l&&r!l&&!r
122
$_[0] == 1 and int $_[0] == $_[0]
!ll&&!rl&&r
401
int $_[0] != $_[0] and $_[0] > 0 and $_[0] < 2
!ll&&!rl&&r
202
int $_[0] != $_[0] and $_[0] > 0
!ll&&!rl&&r
202
MC/DC40%2/5
$_[0] == 1 && int $_[0] == $_[0] || int $_[0] != $_[0] && $_[0] > 0 && $_[0] < 2
$_[0] == 1 int $_[0] == $_[0] int $_[0] != $_[0] $_[0] > 0 $_[0] < 2
Truth table33%3/9
A and B || C and D and E
A= $_[0] == 1B= int $_[0] == $_[0]C= int $_[0] != $_[0]D= $_[0] > 0E= $_[0] < 2
ABCDEresult
11XXX1
0X1111
101111
0X0XX0
0X10X0
0X1100
100XX0
1010X0
101100
1952 int( $_[0] ) == $_[0]
1953 )
1954 ||
1955 (
1956 int( $_[0] ) != $_[0] &&
1957 $_[0] > 0 &&
1958 # Include all non-integers between 0 and 2 for 'one'
1959 $_[0] < 2
1960 )
1961 },
1962 2 ▶ two => sub { $_[0] == 2 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 2 and int $_[0] == $_[0] 1 1 2
1963 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1964 },
1965 # The other locales in this group are aliased
1966  
1967 # iu naq sat se sma smi smj smn sms
1968 iu =>
1969 {
1970 3 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 1 2 3
1971 2 ▶ two => sub { $_[0] == 2 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 2 and int $_[0] == $_[0] 1 1 2
1972 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1973 },
1974 # The other locales in this group are aliased
1975  
1976 # 3: one, few, other
1977 # shi
1978 shi =>
1979 {
1980 5 ▶ one => sub { $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 1 1 4 5
1981 few => sub
1982 3 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.1
1983 3 ▶ $_[0] >= 2 &&
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 2 and $_[0] <= 10 and int $_[0] == $_[0] 2 1 3
Condition66%2/3
$_[0] >= 2 and $_[0] <= 10
!ll&&!rl&&r
012
MC/DC50%1/2
$_[0] >= 2 and $_[0] <= 10
$_[0] >= 2 $_[0] <= 10
Truth table66%2/3
A and B
A= $_[0] >= 2B= $_[0] <= 10
ABresult
0X0
100
111
1984 $_[0] <= 10 &&
1985 int( $_[0] ) == $_[0]
1986 },
1987 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
1988 },
1989 # mo ro
1990 mo =>
1991 {
1992 6 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 1 5 6
1993 few => sub
1994 5 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.2
1995 5 ▶ int( $_[0] ) != $_[0] ||
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] != $_[0] or $_[0] == 0 or $_[0] % 100 >= 1 and $_[0] % 100 <= 19 and $_[0] != 1 3 2 5
Condition83%10/12
int $_[0] != $_[0] || $_[0] == 0 || $_[0] % 100 >= 1 && $_[0] % 100 <= 19 && $_[0] != 1
l!l&&r!l&&!r
311
int $_[0] != $_[0] or $_[0] == 0
l!l&&r!l&&!r
212
$_[0] % 100 >= 1 and $_[0] % 100 <= 19 and $_[0] != 1
!ll&&!rl&&r
101
$_[0] % 100 >= 1 and $_[0] % 100 <= 19
!ll&&!rl&&r
011
MC/DC60%3/5
int $_[0] != $_[0] || $_[0] == 0 || $_[0] % 100 >= 1 && $_[0] % 100 <= 19 && $_[0] != 1
int $_[0] != $_[0] $_[0] == 0 $_[0] % 100 >= 1 $_[0] % 100 <= 19 $_[0] != 1
Truth table66%4/6
A or B || C and D and E
A= int $_[0] != $_[0]B= $_[0] == 0C= $_[0] % 100 >= 1D= $_[0] % 100 <= 19E= $_[0] != 1
ABCDEresult
1XXXX1
01XXX1
001111
000XX0
0010X0
001100
1996 $_[0] == 0 ||
1997 (
1998 $_[0] % 100 >= 1 &&
1999 $_[0] % 100 <= 19 &&
2000 $_[0] != 1
2001 )
2002 },
2003 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2004 },
2005 # The other locales in this group are aliased
2006  
2007 # bs (Bosnian) hr sh sr
2008 bs =>
2009 {
2010 one => sub
2011 11 ▶ {
Subroutine __ANON__: called CC=9 SCAR=22.3
2012 (
2013 11 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11 or int $_[0] != $_[0] and $_[0] < "1.1" and $_[0] > 0 and $_[0] < "0.2" 2 9 11
Condition83%20/24
int $_[0] == $_[0] && ($_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11) || int $_[0] != $_[0] && $_[0] < 1.1 && $_[0] > 0 && $_[0] < 0.2
l!l&&r!l&&!r
218
int $_[0] == $_[0] and $_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11
!ll&&!rl&&r
452
$_[0] % 10 == 1 and $_[0] % 100 != 11 or int($_[0] * 10) % 10 == 1 and int($_[0] * 100) % 100 != 11
l!l&&r!l&&!r
205
$_[0] % 10 == 1 and $_[0] % 100 != 11
!ll&&!rl&&r
412
int($_[0] * 10) % 10 == 1 and int($_[0] * 100) % 100 != 11
!ll&&!rl&&r
500
int $_[0] != $_[0] and $_[0] < "1.1" and $_[0] > 0 and $_[0] < "0.2"
!ll&&!rl&&r
711
int $_[0] != $_[0] and $_[0] < "1.1" and $_[0] > 0
!ll&&!rl&&r
702
int $_[0] != $_[0] and $_[0] < "1.1"
!ll&&!rl&&r
522
MC/DC55%5/9
int $_[0] == $_[0] && ($_[0] % 10 == 1 && $_[0] % 100 != 11 || int($_[0] * 10) % 10 == 1 && int($_[0] * 100) % 100 != 11) || int $_[0] != $_[0] && $_[0] < 1.1 && $_[0] > 0 && $_[0] < 0.2
int $_[0] == $_[0] $_[0] % 10 == 1 $_[0] % 100 != 11 int($_[0] * 10) % 10 == 1 int($_[0] * 100) % 100 != 11 int $_[0] != $_[0] $_[0] < "1.1" $_[0] > 0 $_[0] < "0.2"
Truth table21%6/28
A and B and C or D and E || F and G and H and I
A= int $_[0] == $_[0]B= $_[0] % 10 == 1C= $_[0] % 100 != 11D= int($_[0] * 10) % 10 == 1E= int($_[0] * 100) % 100 != 11F= int $_[0] != $_[0]G= $_[0] < "1.1"H= $_[0] > 0I= $_[0] < "0.2"
ABCDEFGHIresult
111XXXXXX1
10X11XXXX1
11011XXXX1
0XXXX11111
10X0X11111
10X1011111
1100X11111
1101011111
0XXXX0XXX0
0XXXX10XX0
0XXXX110X0
0XXXX11100
10X0X0XXX0
10X0X10XX0
10X0X110X0
10X0X11100
10X100XXX0
10X1010XX0
10X10110X0
10X1011100
1100X0XXX0
1100X10XX0
1100X110X0
1100X11100
110100XXX0
1101010XX0
11010110X0
1101011100
2014 (
2015 (
2016 $_[0] % 10 == 1 &&
2017 $_[0] % 100 != 11
2018 )
2019 ||
2020 (
2021 int( $_[0] * 10 ) % 10 == 1 &&
2022 int( $_[0] * 100 ) % 100 != 11
2023 )
2024 )
2025 )
2026 ||
2027 # Handle decimals for 'one'
2028 (
2029 int( $_[0] ) != $_[0] &&
2030 $_[0] < 1.1 &&
2031 $_[0] > 0 &&
2032 # Exclude numbers like 0.2 from being 'one'
2033 $_[0] < 0.2
2034 )
2035 },
2036 few => sub
2037 8 ▶ {
Subroutine __ANON__: called CC=17 SCAR=32.6
2038 (
2039 8 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && $_[0] % 100 < 10 || $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && $_[0] % 100 >= 20 || int($_[0] * 10) % 10 >= 2 && int($_[0] * 10) % 10 <= 4 && int($_[0] * 100) % 100 < 10 || int($_[0] * 10) % 10 >= 2 && int($_[0] * 10) % 10 <= 4 && int($_[0] * 100) % 100 >= 20 or int $_[0] != $_[0] and ($_[0] >= "0.2" and $_[0] < "1.2" and $_[0] != "1.1") 3 5 8
Condition66%32/48
int $_[0] == $_[0] && ($_[0] % 10 >= 2 && $_[0] % 10 <= 4 && $_[0] % 100 < 10 || $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && $_[0] % 100 >= 20 || int($_[0] * 10) % 10 >= 2 && int($_[0] * 10) % 10 <= 4 && int($_[0] * 100) % 100 < 10 || int($_[0] * 10) % 10 >= 2 && int($_[0] * 10) % 10 <= 4 && int($_[0] * 100) % 100 >= 20) || int $_[0] != $_[0] && ($_[0] >= 0.2 && $_[0] < 1.2 && $_[0] != 1.1)
l!l&&r!l&&!r
314
int $_[0] == $_[0] and $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && $_[0] % 100 < 10 || $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && $_[0] % 100 >= 20 || int($_[0] * 10) % 10 >= 2 && int($_[0] * 10) % 10 <= 4 && int($_[0] * 100) % 100 < 10 || int($_[0] * 10) % 10 >= 2 && int($_[0] * 10) % 10 <= 4 && int($_[0] * 100) % 100 >= 20
!ll&&!rl&&r
323
$_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 < 10 or $_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 >= 20 or int($_[0] * 10) % 10 >= 2 and int($_[0] * 10) % 10 <= 4 and int($_[0] * 100) % 100 < 10 or int($_[0] * 10) % 10 >= 2 and int($_[0] * 10) % 10 <= 4 and int($_[0] * 100) % 100 >= 20
l!l&&r!l&&!r
302
$_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 < 10 or $_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 >= 20 or int($_[0] * 10) % 10 >= 2 and int($_[0] * 10) % 10 <= 4 and int($_[0] * 100) % 100 < 10
l!l&&r!l&&!r
302
$_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 < 10 or $_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 >= 20
l!l&&r!l&&!r
302
$_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 < 10
!ll&&!rl&&r
203
$_[0] % 10 >= 2 and $_[0] % 10 <= 4
!ll&&!rl&&r
113
$_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 >= 20
!ll&&!rl&&r
200
$_[0] % 10 >= 2 and $_[0] % 10 <= 4
!ll&&!rl&&r
110
int($_[0] * 10) % 10 >= 2 and int($_[0] * 10) % 10 <= 4 and int($_[0] * 100) % 100 < 10
!ll&&!rl&&r
200
int($_[0] * 10) % 10 >= 2 and int($_[0] * 10) % 10 <= 4
!ll&&!rl&&r
200
int($_[0] * 10) % 10 >= 2 and int($_[0] * 10) % 10 <= 4 and int($_[0] * 100) % 100 >= 20
!ll&&!rl&&r
200
int($_[0] * 10) % 10 >= 2 and int($_[0] * 10) % 10 <= 4
!ll&&!rl&&r
200
int $_[0] != $_[0] and ($_[0] >= "0.2" and $_[0] < "1.2" and $_[0] != "1.1")
!ll&&!rl&&r
221
$_[0] >= "0.2" and $_[0] < "1.2" and $_[0] != "1.1"
!ll&&!rl&&r
111
$_[0] >= "0.2" and $_[0] < "1.2"
!ll&&!rl&&r
012
MC/DC0%0/17
int $_[0] == $_[0] && ($_[0] % 10 >= 2 && $_[0] % 10 <= 4 && $_[0] % 100 < 10 || $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && $_[0] % 100 >= 20 || int($_[0] * 10) % 10 >= 2 && int($_[0] * 10) % 10 <= 4 && int($_[0] * 100) % 100 < 10 || int($_[0] * 10) % 10 >= 2 && int($_[0] * 10) % 10 <= 4 && int($_[0] * 100) % 100 >= 20) || int $_[0] != $_[0] && ($_[0] >= 0.2 && $_[0] < 1.2 && $_[0] != 1.1)
too many conditions
2040 (
2041 (
2042 $_[0] % 10 >= 2 &&
2043 $_[0] % 10 <= 4 &&
2044 $_[0] % 100 < 10
2045 )
2046 ||
2047 (
2048 $_[0] % 10 >= 2 &&
2049 $_[0] % 10 <= 4 &&
2050 $_[0] % 100 >= 20
2051 )
2052 ||
2053 (
2054 int( $_[0] * 10 ) % 10 >= 2 &&
2055 int( $_[0] * 10 ) % 10 <= 4 &&
2056 int( $_[0] * 100 ) % 100 < 10
2057 )
2058 ||
2059 (
2060 int( $_[0] * 10 ) % 10 >= 2 &&
2061 int( $_[0] * 10 ) % 10 <= 4 &&
2062 int( $_[0] * 100 ) % 100 >= 20
2063 )
2064 )
2065 )
2066 ||
2067 # Handle decimals for 'few' including numbers like 0.2 but not 1.1
2068 (
2069 int( $_[0] ) != $_[0] &&
2070 (
2071 $_[0] >= 0.2 &&
2072 $_[0] < 1.2 &&
2073 # Exclude 1.1 specifically
2074 $_[0] != 1.1
2075 )
2076 )
2077 },
2078 many => sub
2079 4 ▶ {
Subroutine __ANON__: called CC=15 SCAR=42.4
2080 4 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 10 >= 5 && $_[0] % 10 <= 9 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14 || (int($_[0] * 10) % 10 == 0 || int($_[0] * 10) % 10 >= 5 && int($_[0] * 10) % 10 <= 9 || int($_[0] * 100) % 100 >= 11 && int($_[0] * 100) % 100 <= 14) and not $_[0] == 11 || $_[0] == 5 and not $_[0] >= "1.1" && $_[0] < "1.5" 0 4 4
Condition35%15/42
int $_[0] == $_[0] && ($_[0] % 10 == 0 || $_[0] % 10 >= 5 && $_[0] % 10 <= 9 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14 || (int($_[0] * 10) % 10 == 0 || int($_[0] * 10) % 10 >= 5 && int($_[0] * 10) % 10 <= 9 || int($_[0] * 100) % 100 >= 11 && int($_[0] * 100) % 100 <= 14)) && !($_[0] == 11 || $_[0] == 5) && !($_[0] >= 1.1 && $_[0] < 1.5)
!ll&&!rl&&r
400
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 10 >= 5 && $_[0] % 10 <= 9 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14 || (int($_[0] * 10) % 10 == 0 || int($_[0] * 10) % 10 >= 5 && int($_[0] * 10) % 10 <= 9 || int($_[0] * 100) % 100 >= 11 && int($_[0] * 100) % 100 <= 14) and not $_[0] == 11 || $_[0] == 5
!ll&&!rl&&r
220
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 10 >= 5 && $_[0] % 10 <= 9 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14 || (int($_[0] * 10) % 10 == 0 || int($_[0] * 10) % 10 >= 5 && int($_[0] * 10) % 10 <= 9 || int($_[0] * 100) % 100 >= 11 && int($_[0] * 100) % 100 <= 14)
!ll&&!rl&&r
202
$_[0] % 10 == 0 or $_[0] % 10 >= 5 and $_[0] % 10 <= 9 or $_[0] % 100 >= 11 and $_[0] % 100 <= 14 or (int($_[0] * 10) % 10 == 0 or int($_[0] * 10) % 10 >= 5 and int($_[0] * 10) % 10 <= 9 or int($_[0] * 100) % 100 >= 11 and int($_[0] * 100) % 100 <= 14)
l!l&&r!l&&!r
200
$_[0] % 10 == 0 or $_[0] % 10 >= 5 and $_[0] % 10 <= 9 or $_[0] % 100 >= 11 and $_[0] % 100 <= 14
l!l&&r!l&&!r
110
$_[0] % 10 == 0 or $_[0] % 10 >= 5 and $_[0] % 10 <= 9
l!l&&r!l&&!r
011
$_[0] % 10 >= 5 and $_[0] % 10 <= 9
!ll&&!rl&&r
101
$_[0] % 100 >= 11 and $_[0] % 100 <= 14
!ll&&!rl&&r
001
int($_[0] * 10) % 10 == 0 or int($_[0] * 10) % 10 >= 5 and int($_[0] * 10) % 10 <= 9 or int($_[0] * 100) % 100 >= 11 and int($_[0] * 100) % 100 <= 14
l!l&&r!l&&!r
000
int($_[0] * 10) % 10 == 0 or int($_[0] * 10) % 10 >= 5 and int($_[0] * 10) % 10 <= 9
l!l&&r!l&&!r
000
int($_[0] * 10) % 10 >= 5 and int($_[0] * 10) % 10 <= 9
!ll&&!rl&&r
000
int($_[0] * 100) % 100 >= 11 and int($_[0] * 100) % 100 <= 14
!ll&&!rl&&r
000
$_[0] == 11 || $_[0] == 5
l!l&&r!l&&!r
110
$_[0] >= 1.1 && $_[0] < 1.5
!ll&&!rl&&r
000
MC/DC0%0/15
int $_[0] == $_[0] && ($_[0] % 10 == 0 || $_[0] % 10 >= 5 && $_[0] % 10 <= 9 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14 || (int($_[0] * 10) % 10 == 0 || int($_[0] * 10) % 10 >= 5 && int($_[0] * 10) % 10 <= 9 || int($_[0] * 100) % 100 >= 11 && int($_[0] * 100) % 100 <= 14)) && !($_[0] == 11 || $_[0] == 5) && !($_[0] >= 1.1 && $_[0] < 1.5)
int $_[0] == $_[0] $_[0] % 10 == 0 $_[0] % 10 >= 5 $_[0] % 10 <= 9 $_[0] % 100 >= 11 $_[0] % 100 <= 14 int($_[0] * 10) % 10 == 0 int($_[0] * 10) % 10 >= 5 int($_[0] * 10) % 10 <= 9 int($_[0] * 100) % 100 >= 11 int($_[0] * 100) % 100 <= 14 $_[0] == 11 $_[0] == 5 $_[0] >= 1.1 $_[0] < 1.5
Truth table2%3/117
A and B or C and D or E and F or G or H and I or J and K and not(L || M) && not(N && O)
A= int $_[0] == $_[0]B= $_[0] % 10 == 0C= $_[0] % 10 >= 5D= $_[0] % 10 <= 9E= $_[0] % 100 >= 11F= $_[0] % 100 <= 14G= int($_[0] * 10) % 10 == 0H= int($_[0] * 10) % 10 >= 5I= int($_[0] * 10) % 10 <= 9J= int($_[0] * 100) % 100 >= 11K= int($_[0] * 100) % 100 <= 14L= $_[0] == 11M= $_[0] == 5N= $_[0] >= 1.1O= $_[0] < 1.5
ABCDEFGHIJKLMNOresult
0XXXXXXXXXXXXXX0
100X0X00X0XXXXX0
100X0X00X10XXXX0
100X0X0100XXXXX0
100X0X01010XXXX0
100X1000X0XXXXX0
100X1000X10XXXX0
100X100100XXXXX0
100X1001010XXXX0
10100X00X0XXXXX0
10100X00X10XXXX0
10100X0100XXXXX0
10100X01010XXXX0
10101000X0XXXXX0
10101000X10XXXX0
1010100100XXXXX0
10101001010XXXX0
11XXXXXXXXX1XXX0
11XXXXXXXXX01XX0
1011XXXXXXX1XXX0
1011XXXXXXX01XX0
100X11XXXXX1XXX0
100X11XXXXX01XX0
101011XXXXX1XXX0
101011XXXXX01XX0
100X0X1XXXX1XXX0
100X0X1XXXX01XX0
100X0X011XX1XXX0
100X0X011XX01XX0
100X0X00X111XXX0
100X0X00X1101XX0
100X0X010111XXX0
100X0X0101101XX0
100X101XXXX1XXX0
100X101XXXX01XX0
100X10011XX1XXX0
100X10011XX01XX0
100X1000X111XXX0
100X1000X1101XX0
100X10010111XXX0
100X100101101XX0
10100X1XXXX1XXX0
10100X1XXXX01XX0
10100X011XX1XXX0
10100X011XX01XX0
10100X00X111XXX0
10100X00X1101XX0
10100X010111XXX0
10100X0101101XX0
1010101XXXX1XXX0
1010101XXXX01XX0
101010011XX1XXX0
101010011XX01XX0
10101000X111XXX0
10101000X1101XX0
101010010111XXX0
1010100101101XX0
11XXXXXXXXX00110
1011XXXXXXX00110
100X11XXXXX00110
101011XXXXX00110
100X0X1XXXX00110
100X0X011XX00110
100X0X00X1100110
100X0X0101100110
100X101XXXX00110
100X10011XX00110
100X1000X1100110
100X100101100110
10100X1XXXX00110
10100X011XX00110
10100X00X1100110
10100X0101100110
1010101XXXX00110
101010011XX00110
10101000X1100110
1010100101100110
11XXXXXXXXX000X1
11XXXXXXXXX00101
1011XXXXXXX000X1
1011XXXXXXX00101
100X11XXXXX000X1
100X11XXXXX00101
101011XXXXX000X1
101011XXXXX00101
100X0X1XXXX000X1
100X0X1XXXX00101
100X0X011XX000X1
100X0X011XX00101
100X0X00X11000X1
100X0X00X1100101
100X0X01011000X1
100X0X0101100101
100X101XXXX000X1
100X101XXXX00101
100X10011XX000X1
100X10011XX00101
100X1000X11000X1
100X1000X1100101
100X1001011000X1
100X100101100101
10100X1XXXX000X1
10100X1XXXX00101
10100X011XX000X1
10100X011XX00101
10100X00X11000X1
10100X00X1100101
10100X01011000X1
10100X0101100101
1010101XXXX000X1
1010101XXXX00101
101010011XX000X1
101010011XX00101
10101000X11000X1
10101000X1100101
10101001011000X1
1010100101100101
2081 (
2082 (
2083 $_[0] % 10 == 0 ||
2084 (
2085 $_[0] % 10 >= 5 &&
2086 $_[0] % 10 <= 9
2087 )
2088 ||
2089 (
2090 $_[0] % 100 >= 11 &&
2091 $_[0] % 100 <= 14
2092 )
2093 )
2094 ||
2095 (
2096 int( $_[0] * 10 ) % 10 == 0 ||
2097 (
2098 int( $_[0] * 10 ) % 10 >= 5 &&
2099 int( $_[0] * 10 ) % 10 <= 9
2100 )
2101 ||
2102 (
2103 int( $_[0] * 100 ) % 100 >= 11 &&
2104 int( $_[0] * 100 ) % 100 <= 14
2105 )
2106 )
2107 )
2108 &&
2109 # Exclude specific cases that should be 'other'
2110 !( $_[0] == 11 || $_[0] == 5 )
2111 &&
2112 # Exclude decimals that should be 'few'
2113 !( $_[0] >= 1.1 && $_[0] < 1.5 )
2114 },
2115 4 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2116 },
2117 # The other locales in this group are aliased
2118  
2119 # 3: one, many, other
2120 # fr
2121 fr =>
2122 {
2123 7 ▶ one => sub { $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 1 1 6 7
2124 many => sub
2125 5 ▶ {
Subroutine __ANON__: called CC=10 SCAR=24.2
2126 (
2127 5 ▶ int( $_[0] ) != $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] != $_[0] and (int $_[0] * 1000000 != int($_[0]) * 1000000 and not $_[0] - int($_[0]) == "0.5" && int($_[0]) % 1000000 != 0) or int $_[0] != 0 and $_[0] % 1000000 == 0 || int($_[0]) % 1000000 == 0 && $_[0] != int $_[0] and int $_[0] == $_[0] and $_[0] > 1 2 3 5
Condition74%20/27
int $_[0] != $_[0] && (int $_[0] * 1000000 != int($_[0]) * 1000000 && !($_[0] - int($_[0]) == 0.5 && int($_[0]) % 1000000 != 0)) || int $_[0] != 0 && ($_[0] % 1000000 == 0 || int($_[0]) % 1000000 == 0 && $_[0] != int $_[0]) && int $_[0] == $_[0] && $_[0] > 1
l!l&&r!l&&!r
212
int $_[0] != $_[0] and (int $_[0] * 1000000 != int($_[0]) * 1000000 and not $_[0] - int($_[0]) == "0.5" && int($_[0]) % 1000000 != 0)
!ll&&!rl&&r
212
int $_[0] * 1000000 != int($_[0]) * 1000000 and not $_[0] - int($_[0]) == "0.5" && int($_[0]) % 1000000 != 0
!ll&&!rl&&r
012
$_[0] - int($_[0]) == 0.5 && int($_[0]) % 1000000 != 0
!ll&&!rl&&r
111
int $_[0] != 0 and $_[0] % 1000000 == 0 || int($_[0]) % 1000000 == 0 && $_[0] != int $_[0] and int $_[0] == $_[0] and $_[0] > 1
!ll&&!rl&&r
201
int $_[0] != 0 and $_[0] % 1000000 == 0 || int($_[0]) % 1000000 == 0 && $_[0] != int $_[0] and int $_[0] == $_[0]
!ll&&!rl&&r
201
int $_[0] != 0 and $_[0] % 1000000 == 0 || int($_[0]) % 1000000 == 0 && $_[0] != int $_[0]
!ll&&!rl&&r
021
$_[0] % 1000000 == 0 or int($_[0]) % 1000000 == 0 and $_[0] != int $_[0]
l!l&&r!l&&!r
102
int($_[0]) % 1000000 == 0 and $_[0] != int $_[0]
!ll&&!rl&&r
200
MC/DC40%4/10
int $_[0] != $_[0] && (int $_[0] * 1000000 != int($_[0]) * 1000000 && !($_[0] - int($_[0]) == 0.5 && int($_[0]) % 1000000 != 0)) || int $_[0] != 0 && ($_[0] % 1000000 == 0 || int($_[0]) % 1000000 == 0 && $_[0] != int $_[0]) && int $_[0] == $_[0] && $_[0] > 1
int $_[0] != $_[0] int $_[0] * 1000000 != int($_[0]) * 1000000 $_[0] - int($_[0]) == 0.5 int($_[0]) % 1000000 != 0 int $_[0] != 0 $_[0] % 1000000 == 0 int($_[0]) % 1000000 == 0 $_[0] != int $_[0] int $_[0] == $_[0] $_[0] > 1
Truth table17%5/29
A and B and not(C && D) || E and F or G and H and I and J
A= int $_[0] != $_[0]B= int $_[0] * 1000000 != int($_[0]) * 1000000C= $_[0] - int($_[0]) == 0.5D= int($_[0]) % 1000000 != 0E= int $_[0] != 0F= $_[0] % 1000000 == 0G= int($_[0]) % 1000000 == 0H= $_[0] != int $_[0]I= int $_[0] == $_[0]J= $_[0] > 1
ABCDEFGHIJresult
110XXXXXXX1
1110XXXXXX1
0XXX11XX111
0XXX1011111
10XX11XX111
10XX1011111
111111XX111
11111011111
0XXX0XXXXX0
0XXX100XXX0
0XXX1010XX0
0XXX11XX0X0
0XXX10110X0
0XXX11XX100
0XXX1011100
10XX0XXXXX0
10XX100XXX0
10XX1010XX0
10XX11XX0X0
10XX10110X0
10XX11XX100
10XX1011100
11110XXXXX0
1111100XXX0
11111010XX0
111111XX0X0
111110110X0
111111XX100
11111011100
2128 (
2129 # Check if there's a fractional part but exclude exact half-integers like 1.5
2130 int( $_[0] * 1000000 ) != int( $_[0] ) * 1000000 &&
2131 # Explicitly exclude numbers like 1.5 but allow numbers like 1000000.5
2132 !($_[0] - int( $_[0]) == 0.5 && int( $_[0] ) % 1000000 != 0)
2133 )
2134 )
2135 ||
2136 (
2137 int( $_[0] ) != 0 &&
2138 (
2139 $_[0] % 1000000 == 0 ||
2140 # Handle cases like 1000000.5 where the integer part is divisible by 1,000,000
2141 (int( $_[0] ) % 1000000 == 0 && $_[0] != int( $_[0] ))
2142 ) &&
2143 int( $_[0] ) == $_[0] &&
2144 $_[0] > 1
2145 )
2146 },
2147 2 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2148 },
2149 # pt
2150 pt =>
2151 {
2152 0 ▶ one => sub { $_[0] == 0 || $_[0] == 1 },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or $_[0] == 1 0 0 0
2153 many => sub
2154 0 ▶ {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2155 0 ▶ int( $_[0] ) != $_[0] ||
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] != $_[0] or int $_[0] != 0 and $_[0] % 1000000 == 0 and int $_[0] == $_[0] 0 0 0
Condition0%0/9
int $_[0] != $_[0] || int $_[0] != 0 && $_[0] % 1000000 == 0 && int $_[0] == $_[0]
l!l&&r!l&&!r
000
int $_[0] != 0 and $_[0] % 1000000 == 0 and int $_[0] == $_[0]
!ll&&!rl&&r
000
int $_[0] != 0 and $_[0] % 1000000 == 0
!ll&&!rl&&r
000
MC/DC0%0/4
int $_[0] != $_[0] || int $_[0] != 0 && $_[0] % 1000000 == 0 && int $_[0] == $_[0]
int $_[0] != $_[0] int $_[0] != 0 $_[0] % 1000000 == 0 int $_[0] == $_[0]
Truth table0%0/5
A || B and C and D
A= int $_[0] != $_[0]B= int $_[0] != 0C= $_[0] % 1000000 == 0D= int $_[0] == $_[0]
ABCDresult
1XXX1
01111
00XX0
010X0
01100
2156 (
2157 int( $_[0] ) != 0 &&
2158 $_[0] % 1000000 == 0 &&
2159 int( $_[0] ) == $_[0]
2160 )
2161 },
2162 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2163 },
2164 # ca it lld pt_PT scn vec
2165 ca =>
2166 {
2167 0 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 0 0 0
2168 many => sub
2169 0 ▶ {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2170 0 ▶ int( $_[0] ) != $_[0] ||
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] != $_[0] or int $_[0] != 0 and $_[0] % 1000000 == 0 and int $_[0] == $_[0] 0 0 0
Condition0%0/9
int $_[0] != $_[0] || int $_[0] != 0 && $_[0] % 1000000 == 0 && int $_[0] == $_[0]
l!l&&r!l&&!r
000
int $_[0] != 0 and $_[0] % 1000000 == 0 and int $_[0] == $_[0]
!ll&&!rl&&r
000
int $_[0] != 0 and $_[0] % 1000000 == 0
!ll&&!rl&&r
000
MC/DC0%0/4
int $_[0] != $_[0] || int $_[0] != 0 && $_[0] % 1000000 == 0 && int $_[0] == $_[0]
int $_[0] != $_[0] int $_[0] != 0 $_[0] % 1000000 == 0 int $_[0] == $_[0]
Truth table0%0/5
A || B and C and D
A= int $_[0] != $_[0]B= int $_[0] != 0C= $_[0] % 1000000 == 0D= int $_[0] == $_[0]
ABCDresult
1XXX1
01111
00XX0
010X0
01100
2171 (
2172 int( $_[0] ) != 0 &&
2173 $_[0] % 1000000 == 0 &&
2174 int( $_[0] ) == $_[0]
2175 )
2176 },
2177 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2178 },
2179 # The other locales in this group are aliased
2180  
2181 # es
2182 es =>
2183 {
2184 0 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 0 0 0
2185 many => sub
2186 0 ▶ {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2187 0 ▶ int( $_[0]) != $_[0] ||
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] != $_[0] or int $_[0] != 0 and $_[0] % 1000000 == 0 and int $_[0] == $_[0] 0 0 0
Condition0%0/9
int $_[0] != $_[0] || int $_[0] != 0 && $_[0] % 1000000 == 0 && int $_[0] == $_[0]
l!l&&r!l&&!r
000
int $_[0] != 0 and $_[0] % 1000000 == 0 and int $_[0] == $_[0]
!ll&&!rl&&r
000
int $_[0] != 0 and $_[0] % 1000000 == 0
!ll&&!rl&&r
000
MC/DC0%0/4
int $_[0] != $_[0] || int $_[0] != 0 && $_[0] % 1000000 == 0 && int $_[0] == $_[0]
int $_[0] != $_[0] int $_[0] != 0 $_[0] % 1000000 == 0 int $_[0] == $_[0]
Truth table0%0/5
A || B and C and D
A= int $_[0] != $_[0]B= int $_[0] != 0C= $_[0] % 1000000 == 0D= int $_[0] == $_[0]
ABCDresult
1XXX1
01111
00XX0
010X0
01100
2188 (
2189 int( $_[0] ) != 0 &&
2190 $_[0] % 1000000 == 0 &&
2191 int( $_[0] ) == $_[0]
2192 )
2193 },
2194 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2195 },
2196  
2197 # 4: one, two, few, other
2198 # gd
2199 gd =>
2200 {
2201 9 ▶ one => sub { $_[0] == 1 || $_[0] == 11 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 or $_[0] == 11 1 8 9
2202 7 ▶ two => sub { $_[0] == 2 || $_[0] == 12 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 2 or $_[0] == 12 1 6 7
2203 few => sub
2204 5 ▶ {
Subroutine __ANON__: called CC=4 SCAR=16.9
2205 5 ▶ $_[0] >= 3 &&
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 3 and $_[0] <= 10 || $_[0] >= 13 and $_[0] <= 19 5 0 5
Condition50%3/6
$_[0] >= 3 and $_[0] <= 10 || $_[0] >= 13
!ll&&!rl&&r
005
$_[0] <= 10 or $_[0] >= 13
l!l&&r!l&&!r
230
MC/DC0%0/3
$_[0] >= 3 and $_[0] <= 10 || $_[0] >= 13
$_[0] >= 3 $_[0] <= 10 $_[0] >= 13
Truth table50%2/4
A and B or C
A= $_[0] >= 3B= $_[0] <= 10C= $_[0] >= 13
ABCresult
0XX0
1000
11X1
1011
2206 (
2207 $_[0] <= 10 ||
2208 $_[0] >= 13
2209 )
2210 && $_[0] <= 19
2211 },
2212 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2213 },
2214 # sl
2215 sl =>
2216 {
2217 10 ▶ one => sub { int( $_[0]) == $_[0] && $_[0] % 100 == 1 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 == 1 8 2 10
2218 8 ▶ two => sub { int( $_[0]) == $_[0] && $_[0] % 100 == 2 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 == 2 6 2 8
2219 few => sub
2220 6 ▶ {
Subroutine __ANON__: called CC=4 SCAR=13.9
2221 6 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 == 3 || $_[0] % 100 == 4 or int $_[0] != $_[0] 3 3 6
Condition100%6/6
int $_[0] == $_[0] and $_[0] % 100 == 3 || $_[0] % 100 == 4
!ll&&!rl&&r
213
$_[0] % 100 == 3 or $_[0] % 100 == 4
l!l&&r!l&&!r
211
MC/DC100%3/3
int $_[0] == $_[0] and $_[0] % 100 == 3 || $_[0] % 100 == 4
int $_[0] == $_[0] $_[0] % 100 == 3 $_[0] % 100 == 4
Truth table100%4/4
A and B or C
A= int $_[0] == $_[0]B= $_[0] % 100 == 3C= $_[0] % 100 == 4
ABCresult
0XX0
1000
11X1
1011
2222 (
2223 $_[0] % 100 == 3 ||
2224 $_[0] % 100 == 4
2225 )
2226 ||
2227 int( $_[0] ) != $_[0]
2228 },
2229 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2230 },
2231 # dsb (Lower Sorbian) hsb
2232 dsb =>
2233 {
2234 one => sub
2235 9 ▶ {
Subroutine __ANON__: called CC=6 SCAR=18.2
2236 (
2237 9 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 == 1 || int($_[0] * 10) % 100 == 1 or int $_[0] != $_[0] and $_[0] > 0 and $_[0] < "1.1" 2 7 9
Condition80%12/15
int $_[0] == $_[0] && ($_[0] % 100 == 1 || int($_[0] * 10) % 100 == 1) || int $_[0] != $_[0] && $_[0] > 0 && $_[0] < 1.1
l!l&&r!l&&!r
216
int $_[0] == $_[0] and $_[0] % 100 == 1 || int($_[0] * 10) % 100 == 1
!ll&&!rl&&r
162
$_[0] % 100 == 1 or int($_[0] * 10) % 100 == 1
l!l&&r!l&&!r
206
int $_[0] != $_[0] and $_[0] > 0 and $_[0] < "1.1"
!ll&&!rl&&r
601
int $_[0] != $_[0] and $_[0] > 0
!ll&&!rl&&r
601
MC/DC16%1/6
int $_[0] == $_[0] && ($_[0] % 100 == 1 || int($_[0] * 10) % 100 == 1) || int $_[0] != $_[0] && $_[0] > 0 && $_[0] < 1.1
int $_[0] == $_[0] $_[0] % 100 == 1 int($_[0] * 10) % 100 == 1 int $_[0] != $_[0] $_[0] > 0 $_[0] < "1.1"
Truth table30%3/10
A and B or C || D and E and F
A= int $_[0] == $_[0]B= $_[0] % 100 == 1C= int($_[0] * 10) % 100 == 1D= int $_[0] != $_[0]E= $_[0] > 0F= $_[0] < "1.1"
ABCDEFresult
11XXXX1
101XXX1
0XX1111
1001111
0XX0XX0
0XX10X0
0XX1100
1000XX0
10010X0
1001100
2238 (
2239 ( $_[0] % 100 == 1 )
2240 ||
2241 ( int( $_[0] * 10 ) % 100 == 1 )
2242 )
2243 )
2244 ||
2245 # Handle decimals for 'one'
2246 (
2247 int( $_[0] ) != $_[0] &&
2248 $_[0] > 0 &&
2249 $_[0] < 1.1
2250 )
2251 },
2252 two => sub
2253 6 ▶ {
Subroutine __ANON__: called CC=3 SCAR=12.0
2254 6 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 == 2 || int($_[0] * 10) % 100 == 2 6 0 6
Condition66%4/6
int $_[0] == $_[0] && ($_[0] % 100 == 2 || int($_[0] * 10) % 100 == 2)
!ll&&!rl&&r
042
$_[0] % 100 == 2 or int($_[0] * 10) % 100 == 2
l!l&&r!l&&!r
204
MC/DC33%1/3
int $_[0] == $_[0] && ($_[0] % 100 == 2 || int($_[0] * 10) % 100 == 2)
int $_[0] == $_[0] $_[0] % 100 == 2 int($_[0] * 10) % 100 == 2
Truth table50%2/4
A && B or C
A= int $_[0] == $_[0]B= $_[0] % 100 == 2C= int($_[0] * 10) % 100 == 2
ABCresult
0XX0
1000
11X1
1011
2255 (
2256 ( $_[0] % 100 == 2 )
2257 ||
2258 ( int( $_[0] * 10 ) % 100 == 2 )
2259 )
2260 },
2261 few => sub
2262 4 ▶ {
Subroutine __ANON__: called CC=5 SCAR=18.9
2263 4 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 >= 3 && $_[0] % 100 <= 4 || int($_[0] * 10) % 100 >= 3 && int($_[0] * 10) % 100 <= 4 4 0 4
Condition58%7/12
int $_[0] == $_[0] && ($_[0] % 100 >= 3 && $_[0] % 100 <= 4 || int($_[0] * 10) % 100 >= 3 && int($_[0] * 10) % 100 <= 4)
!ll&&!rl&&r
013
$_[0] % 100 >= 3 and $_[0] % 100 <= 4 or int($_[0] * 10) % 100 >= 3 and int($_[0] * 10) % 100 <= 4
l!l&&r!l&&!r
301
$_[0] % 100 >= 3 and $_[0] % 100 <= 4
!ll&&!rl&&r
013
int($_[0] * 10) % 100 >= 3 and int($_[0] * 10) % 100 <= 4
!ll&&!rl&&r
010
MC/DC20%1/5
int $_[0] == $_[0] && ($_[0] % 100 >= 3 && $_[0] % 100 <= 4 || int($_[0] * 10) % 100 >= 3 && int($_[0] * 10) % 100 <= 4)
int $_[0] == $_[0] $_[0] % 100 >= 3 $_[0] % 100 <= 4 int($_[0] * 10) % 100 >= 3 int($_[0] * 10) % 100 <= 4
Truth table25%2/8
A && B and C or D and E
A= int $_[0] == $_[0]B= $_[0] % 100 >= 3C= $_[0] % 100 <= 4D= int($_[0] * 10) % 100 >= 3E= int($_[0] * 10) % 100 <= 4
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
2264 (
2265 ( $_[0] % 100 >= 3 && $_[0] % 100 <= 4 )
2266 ||
2267 (
2268 int( $_[0] * 10 ) % 100 >= 3 &&
2269 int( $_[0] * 10 ) % 100 <= 4
2270 )
2271 )
2272 },
2273 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2274 },
2275 # The other locales in this group are aliased
2276  
2277 # 4: one, few, many, other
2278 # cs sk
2279 cs =>
2280 {
2281 6 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 1 5 6
2282 few => sub
2283 5 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
2284 5 ▶ $_[0] >= 2 &&
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 2 and $_[0] <= 4 and int $_[0] == $_[0] 3 2 5
Condition100%3/3
$_[0] >= 2 and $_[0] <= 4
!ll&&!rl&&r
113
MC/DC100%2/2
$_[0] >= 2 and $_[0] <= 4
$_[0] >= 2 $_[0] <= 4
Truth table100%3/3
A and B
A= $_[0] >= 2B= $_[0] <= 4
ABresult
0X0
100
111
2285 $_[0] <= 4 &&
2286 int( $_[0] ) == $_[0]
2287 },
2288 2 ▶ many => sub { int( $_[0] ) != $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
2289 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2290 },
2291 # The other locales in this group are aliased
2292  
2293 # pl (Polish)
2294 pl =>
2295 {
2296 11 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 1 10 11
2297 few => sub
2298 10 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.1
2299 10 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 < 10 || $_[0] % 100 >= 20 5 5 10
Condition91%11/12
int $_[0] == $_[0] && $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && ($_[0] % 100 < 10 || $_[0] % 100 >= 20)
!ll&&!rl&&r
523
int $_[0] == $_[0] and $_[0] % 10 >= 2 and $_[0] % 10 <= 4
!ll&&!rl&&r
325
int $_[0] == $_[0] and $_[0] % 10 >= 2
!ll&&!rl&&r
217
$_[0] % 100 < 10 or $_[0] % 100 >= 20
l!l&&r!l&&!r
302
MC/DC80%4/5
int $_[0] == $_[0] && $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && ($_[0] % 100 < 10 || $_[0] % 100 >= 20)
int $_[0] == $_[0] $_[0] % 10 >= 2 $_[0] % 10 <= 4 $_[0] % 100 < 10 $_[0] % 100 >= 20
Truth table83%5/6
A and B and C && D or E
A= int $_[0] == $_[0]B= $_[0] % 10 >= 2C= $_[0] % 10 <= 4D= $_[0] % 100 < 10E= $_[0] % 100 >= 20
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
2300 $_[0] % 10 >= 2 &&
2301 $_[0] % 10 <= 4 &&
2302 (
2303 $_[0] % 100 < 10 ||
2304 $_[0] % 100 >= 20
2305 )
2306 },
2307 many => sub
2308 7 ▶ {
Subroutine __ANON__: called CC=7 SCAR=21.8
2309 7 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 10 >= 5 && $_[0] % 10 <= 9 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14 or int $_[0] != $_[0] 5 2 7
Condition60%9/15
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 10 >= 5 && $_[0] % 10 <= 9 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14
!ll&&!rl&&r
205
$_[0] % 10 == 0 or $_[0] % 10 >= 5 and $_[0] % 10 <= 9 or $_[0] % 100 >= 11 and $_[0] % 100 <= 14
l!l&&r!l&&!r
230
$_[0] % 10 == 0 or $_[0] % 10 >= 5 and $_[0] % 10 <= 9
l!l&&r!l&&!r
023
$_[0] % 10 >= 5 and $_[0] % 10 <= 9
!ll&&!rl&&r
302
$_[0] % 100 >= 11 and $_[0] % 100 <= 14
!ll&&!rl&&r
003
MC/DC16%1/6
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 10 >= 5 && $_[0] % 10 <= 9 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14
int $_[0] == $_[0] $_[0] % 10 == 0 $_[0] % 10 >= 5 $_[0] % 10 <= 9 $_[0] % 100 >= 11 $_[0] % 100 <= 14
Truth table33%3/9
A and B or C and D or E and F
A= int $_[0] == $_[0]B= $_[0] % 10 == 0C= $_[0] % 10 >= 5D= $_[0] % 10 <= 9E= $_[0] % 100 >= 11F= $_[0] % 100 <= 14
ABCDEFresult
0XXXXX0
100X0X0
100X100
10100X0
1010100
11XXXX1
1011XX1
100X111
1010111
2310 (
2311 $_[0] % 10 == 0 ||
2312 (
2313 $_[0] % 10 >= 5 &&
2314 $_[0] % 10 <= 9
2315 )
2316 ||
2317 (
2318 $_[0] % 100 >= 11 &&
2319 $_[0] % 100 <= 14
2320 )
2321 )
2322 ||
2323 int( $_[0] ) != $_[0]
2324 },
2325 0 ▶ other => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2326 },
2327 # be (Belarusian)
2328 be =>
2329 {
2330 one => sub
2331 8 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
2332 8 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 1 and $_[0] % 100 != 11 3 5 8
Condition100%3/3
int $_[0] == $_[0] and $_[0] % 10 == 1
!ll&&!rl&&r
143
MC/DC100%2/2
int $_[0] == $_[0] and $_[0] % 10 == 1
int $_[0] == $_[0] $_[0] % 10 == 1
Truth table100%3/3
A and B
A= int $_[0] == $_[0]B= $_[0] % 10 == 1
ABresult
0X0
100
111
2333 $_[0] % 10 == 1 &&
2334 $_[0] % 100 != 11
2335 },
2336 few => sub
2337 6 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.5
2338 6 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 < 10 || $_[0] % 100 >= 20 3 3 6
Condition75%9/12
int $_[0] == $_[0] && $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && ($_[0] % 100 < 10 || $_[0] % 100 >= 20)
!ll&&!rl&&r
303
int $_[0] == $_[0] and $_[0] % 10 >= 2 and $_[0] % 10 <= 4
!ll&&!rl&&r
213
int $_[0] == $_[0] and $_[0] % 10 >= 2
!ll&&!rl&&r
114
$_[0] % 100 < 10 or $_[0] % 100 >= 20
l!l&&r!l&&!r
300
MC/DC60%3/5
int $_[0] == $_[0] && $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && ($_[0] % 100 < 10 || $_[0] % 100 >= 20)
int $_[0] == $_[0] $_[0] % 10 >= 2 $_[0] % 10 <= 4 $_[0] % 100 < 10 $_[0] % 100 >= 20
Truth table66%4/6
A and B and C && D or E
A= int $_[0] == $_[0]B= $_[0] % 10 >= 2C= $_[0] % 10 <= 4D= $_[0] % 100 < 10E= $_[0] % 100 >= 20
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
2339 $_[0] % 10 >= 2 &&
2340 $_[0] % 10 <= 4 &&
2341 (
2342 $_[0] % 100 < 10 ||
2343 $_[0] % 100 >= 20
2344 )
2345 },
2346 many => sub
2347 3 ▶ {
Subroutine __ANON__: called CC=5 SCAR=17.8
2348 3 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 10 >= 5 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14 2 1 3
Condition58%7/12
int $_[0] == $_[0] && ($_[0] % 10 == 0 || $_[0] % 10 >= 5 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14)
!ll&&!rl&&r
102
$_[0] % 10 == 0 or $_[0] % 10 >= 5 or $_[0] % 100 >= 11 and $_[0] % 100 <= 14
l!l&&r!l&&!r
110
$_[0] % 10 == 0 or $_[0] % 10 >= 5
l!l&&r!l&&!r
011
$_[0] % 100 >= 11 and $_[0] % 100 <= 14
!ll&&!rl&&r
001
MC/DC20%1/5
int $_[0] == $_[0] && ($_[0] % 10 == 0 || $_[0] % 10 >= 5 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14)
int $_[0] == $_[0] $_[0] % 10 == 0 $_[0] % 10 >= 5 $_[0] % 100 >= 11 $_[0] % 100 <= 14
Truth table50%3/6
A && B or C or D and E
A= int $_[0] == $_[0]B= $_[0] % 10 == 0C= $_[0] % 10 >= 5D= $_[0] % 100 >= 11E= $_[0] % 100 <= 14
ABCDEresult
0XXXX0
1000X0
100100
11XXX1
101XX1
100111
2349 (
2350 (
2351 $_[0] % 10 == 0 ||
2352 $_[0] % 10 >= 5
2353 )
2354 ||
2355 (
2356 $_[0] % 100 >= 11 &&
2357 $_[0] % 100 <= 14
2358 )
2359 )
2360 },
2361 1 ▶ other => sub { int( $_[0] ) != $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
2362 },
2363 # lt (Lithuanian)
2364 lt =>
2365 {
2366 one => sub
2367 7 ▶ {
Subroutine __ANON__: called CC=4 SCAR=13.9
2368 7 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 1 and not $_[0] % 100 >= 11 && $_[0] % 100 <= 19 3 4 7
Condition100%9/9
int $_[0] == $_[0] && $_[0] % 10 == 1 && !($_[0] % 100 >= 11 && $_[0] % 100 <= 19)
!ll&&!rl&&r
412
int $_[0] == $_[0] and $_[0] % 10 == 1
!ll&&!rl&&r
133
$_[0] % 100 >= 11 && $_[0] % 100 <= 19
!ll&&!rl&&r
111
MC/DC100%4/4
int $_[0] == $_[0] && $_[0] % 10 == 1 && !($_[0] % 100 >= 11 && $_[0] % 100 <= 19)
int $_[0] == $_[0] $_[0] % 10 == 1 $_[0] % 100 >= 11 $_[0] % 100 <= 19
Truth table100%5/5
A and B && not(C && D)
A= int $_[0] == $_[0]B= $_[0] % 10 == 1C= $_[0] % 100 >= 11D= $_[0] % 100 <= 19
ABCDresult
0XXX0
10XX0
11110
110X1
11101
2369 $_[0] % 10 == 1 &&
2370 !(
2371 $_[0] % 100 >= 11 &&
2372 $_[0] % 100 <= 19
2373 )
2374 },
2375 few => sub
2376 5 ▶ {
Subroutine __ANON__: called CC=5 SCAR=17.0
2377 5 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 >= 2 and $_[0] % 10 <= 9 and $_[0] % 100 < 10 || $_[0] % 100 >= 20 2 3 5
Condition66%8/12
int $_[0] == $_[0] && $_[0] % 10 >= 2 && $_[0] % 10 <= 9 && ($_[0] % 100 < 10 || $_[0] % 100 >= 20)
!ll&&!rl&&r
302
int $_[0] == $_[0] and $_[0] % 10 >= 2 and $_[0] % 10 <= 9
!ll&&!rl&&r
302
int $_[0] == $_[0] and $_[0] % 10 >= 2
!ll&&!rl&&r
122
$_[0] % 100 < 10 or $_[0] % 100 >= 20
l!l&&r!l&&!r
200
MC/DC40%2/5
int $_[0] == $_[0] && $_[0] % 10 >= 2 && $_[0] % 10 <= 9 && ($_[0] % 100 < 10 || $_[0] % 100 >= 20)
int $_[0] == $_[0] $_[0] % 10 >= 2 $_[0] % 10 <= 9 $_[0] % 100 < 10 $_[0] % 100 >= 20
Truth table50%3/6
A and B and C && D or E
A= int $_[0] == $_[0]B= $_[0] % 10 >= 2C= $_[0] % 10 <= 9D= $_[0] % 100 < 10E= $_[0] % 100 >= 20
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
2378 $_[0] % 10 >= 2 &&
2379 $_[0] % 10 <= 9 &&
2380 (
2381 $_[0] % 100 < 10 ||
2382 $_[0] % 100 >= 20
2383 )
2384 },
2385 3 ▶ many => sub { int( $_[0] ) != $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
2386 other => sub
2387 2 ▶ {
Subroutine __ANON__: called CC=4 SCAR=16.4
2388 2 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and ($_[0] % 100 >= 11 and $_[0] % 100 <= 19 || $_[0] % 10 == 0) 2 0 2
Condition55%5/9
int $_[0] == $_[0] && ($_[0] % 100 >= 11 && ($_[0] % 100 <= 19 || $_[0] % 10 == 0))
!ll&&!rl&&r
011
$_[0] % 100 >= 11 and $_[0] % 100 <= 19 || $_[0] % 10 == 0
!ll&&!rl&&r
101
$_[0] % 100 <= 19 or $_[0] % 10 == 0
l!l&&r!l&&!r
100
MC/DC25%1/4
int $_[0] == $_[0] && ($_[0] % 100 >= 11 && ($_[0] % 100 <= 19 || $_[0] % 10 == 0))
int $_[0] == $_[0] $_[0] % 100 >= 11 $_[0] % 100 <= 19 $_[0] % 10 == 0
Truth table40%2/5
A && B and C or D
A= int $_[0] == $_[0]B= $_[0] % 100 >= 11C= $_[0] % 100 <= 19D= $_[0] % 10 == 0
ABCDresult
0XXX0
10XX0
11000
111X1
11011
2389 (
2390 $_[0] % 100 >= 11 &&
2391 (
2392 $_[0] % 100 <= 19 ||
2393 $_[0] % 10 == 0
2394 )
2395 )
2396 },
2397 },
2398 # ru (Russian) uk (Ukrainian)
2399 ru =>
2400 {
2401 one => sub
2402 8 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
2403 8 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 1 and $_[0] % 100 != 11 3 5 8
Condition100%3/3
int $_[0] == $_[0] and $_[0] % 10 == 1
!ll&&!rl&&r
143
MC/DC100%2/2
int $_[0] == $_[0] and $_[0] % 10 == 1
int $_[0] == $_[0] $_[0] % 10 == 1
Truth table100%3/3
A and B
A= int $_[0] == $_[0]B= $_[0] % 10 == 1
ABresult
0X0
100
111
2404 $_[0] % 10 == 1 &&
2405 $_[0] % 100 != 11
2406 },
2407 few => sub
2408 6 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.5
2409 6 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 >= 2 and $_[0] % 10 <= 4 and $_[0] % 100 < 10 || $_[0] % 100 >= 20 3 3 6
Condition75%9/12
int $_[0] == $_[0] && $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && ($_[0] % 100 < 10 || $_[0] % 100 >= 20)
!ll&&!rl&&r
303
int $_[0] == $_[0] and $_[0] % 10 >= 2 and $_[0] % 10 <= 4
!ll&&!rl&&r
213
int $_[0] == $_[0] and $_[0] % 10 >= 2
!ll&&!rl&&r
114
$_[0] % 100 < 10 or $_[0] % 100 >= 20
l!l&&r!l&&!r
300
MC/DC60%3/5
int $_[0] == $_[0] && $_[0] % 10 >= 2 && $_[0] % 10 <= 4 && ($_[0] % 100 < 10 || $_[0] % 100 >= 20)
int $_[0] == $_[0] $_[0] % 10 >= 2 $_[0] % 10 <= 4 $_[0] % 100 < 10 $_[0] % 100 >= 20
Truth table66%4/6
A and B and C && D or E
A= int $_[0] == $_[0]B= $_[0] % 10 >= 2C= $_[0] % 10 <= 4D= $_[0] % 100 < 10E= $_[0] % 100 >= 20
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
2410 $_[0] % 10 >= 2 &&
2411 $_[0] % 10 <= 4 &&
2412 (
2413 $_[0] % 100 < 10 ||
2414 $_[0] % 100 >= 20
2415 )
2416 },
2417 many => sub
2418 3 ▶ {
Subroutine __ANON__: called CC=5 SCAR=17.8
2419 3 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 0 || $_[0] % 10 >= 5 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14 2 1 3
Condition58%7/12
int $_[0] == $_[0] && ($_[0] % 10 == 0 || $_[0] % 10 >= 5 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14)
!ll&&!rl&&r
102
$_[0] % 10 == 0 or $_[0] % 10 >= 5 or $_[0] % 100 >= 11 and $_[0] % 100 <= 14
l!l&&r!l&&!r
110
$_[0] % 10 == 0 or $_[0] % 10 >= 5
l!l&&r!l&&!r
011
$_[0] % 100 >= 11 and $_[0] % 100 <= 14
!ll&&!rl&&r
001
MC/DC20%1/5
int $_[0] == $_[0] && ($_[0] % 10 == 0 || $_[0] % 10 >= 5 || $_[0] % 100 >= 11 && $_[0] % 100 <= 14)
int $_[0] == $_[0] $_[0] % 10 == 0 $_[0] % 10 >= 5 $_[0] % 100 >= 11 $_[0] % 100 <= 14
Truth table50%3/6
A && B or C or D and E
A= int $_[0] == $_[0]B= $_[0] % 10 == 0C= $_[0] % 10 >= 5D= $_[0] % 100 >= 11E= $_[0] % 100 <= 14
ABCDEresult
0XXXX0
1000X0
100100
11XXX1
101XX1
100111
2420 (
2421 (
2422 $_[0] % 10 == 0 ||
2423 $_[0] % 10 >= 5
2424 )
2425 ||
2426 (
2427 $_[0] % 100 >= 11 &&
2428 $_[0] % 100 <= 14
2429 )
2430 )
2431 },
2432 1 ▶ other => sub { int( $_[0] ) != $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
2433 },
2434 # The other locales in this group are aliased
2435  
2436 # 5: one, two, few, many, other
2437 # br
2438 br =>
2439 {
2440 one => sub
2441 12 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.1
2442 12 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 1 and $_[0] % 100 != 11 and $_[0] % 100 != 71 and $_[0] % 100 != 91 2 10 12
Condition88%8/9
int $_[0] == $_[0] and $_[0] % 10 == 1 and $_[0] % 100 != 11 and $_[0] % 100 != 71
!ll&&!rl&&r
912
int $_[0] == $_[0] and $_[0] % 10 == 1 and $_[0] % 100 != 11
!ll&&!rl&&r
903
int $_[0] == $_[0] and $_[0] % 10 == 1
!ll&&!rl&&r
273
MC/DC75%3/4
int $_[0] == $_[0] and $_[0] % 10 == 1 and $_[0] % 100 != 11 and $_[0] % 100 != 71
int $_[0] == $_[0] $_[0] % 10 == 1 $_[0] % 100 != 11 $_[0] % 100 != 71
Truth table80%4/5
A and B and C and D
A= int $_[0] == $_[0]B= $_[0] % 10 == 1C= $_[0] % 100 != 11D= $_[0] % 100 != 71
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2443 $_[0] % 10 == 1 &&
2444 $_[0] % 100 != 11 &&
2445 $_[0] % 100 != 71 &&
2446 $_[0] % 100 != 91
2447 },
2448 two => sub
2449 10 ▶ {
Subroutine __ANON__: called CC=5 SCAR=16.3
2450 10 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 2 and $_[0] % 100 != 12 and $_[0] % 100 != 72 and $_[0] % 100 != 92 2 8 10
Condition77%7/9
int $_[0] == $_[0] and $_[0] % 10 == 2 and $_[0] % 100 != 12 and $_[0] % 100 != 72
!ll&&!rl&&r
802
int $_[0] == $_[0] and $_[0] % 10 == 2 and $_[0] % 100 != 12
!ll&&!rl&&r
802
int $_[0] == $_[0] and $_[0] % 10 == 2
!ll&&!rl&&r
262
MC/DC50%2/4
int $_[0] == $_[0] and $_[0] % 10 == 2 and $_[0] % 100 != 12 and $_[0] % 100 != 72
int $_[0] == $_[0] $_[0] % 10 == 2 $_[0] % 100 != 12 $_[0] % 100 != 72
Truth table60%3/5
A and B and C and D
A= int $_[0] == $_[0]B= $_[0] % 10 == 2C= $_[0] % 100 != 12D= $_[0] % 100 != 72
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2451 $_[0] % 10 == 2 &&
2452 $_[0] % 100 != 12 &&
2453 $_[0] % 100 != 72 &&
2454 $_[0] % 100 != 92
2455 },
2456 few => sub
2457 8 ▶ {
Subroutine __ANON__: called CC=10 SCAR=25.4
2458 8 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and ($_[0] % 10 >= 3 and $_[0] % 10 <= 4 || $_[0] % 10 == 9 and $_[0] % 100 < 10 || $_[0] % 100 > 19 and $_[0] % 100 < 70 || $_[0] % 100 > 79 and $_[0] % 100 < 90 || $_[0] % 100 > 99) 6 2 8
Condition66%18/27
int $_[0] == $_[0] && ($_[0] % 10 >= 3 && ($_[0] % 10 <= 4 || $_[0] % 10 == 9) && ($_[0] % 100 < 10 || $_[0] % 100 > 19) && ($_[0] % 100 < 70 || $_[0] % 100 > 79) && ($_[0] % 100 < 90 || $_[0] % 100 > 99))
!ll&&!rl&&r
233
$_[0] % 10 >= 3 and $_[0] % 10 <= 4 || $_[0] % 10 == 9 and $_[0] % 100 < 10 || $_[0] % 100 > 19 and $_[0] % 100 < 70 || $_[0] % 100 > 79 and $_[0] % 100 < 90 || $_[0] % 100 > 99
!ll&&!rl&&r
303
$_[0] % 10 >= 3 and $_[0] % 10 <= 4 || $_[0] % 10 == 9 and $_[0] % 100 < 10 || $_[0] % 100 > 19 and $_[0] % 100 < 70 || $_[0] % 100 > 79
!ll&&!rl&&r
303
$_[0] % 10 >= 3 and $_[0] % 10 <= 4 || $_[0] % 10 == 9 and $_[0] % 100 < 10 || $_[0] % 100 > 19
!ll&&!rl&&r
303
$_[0] % 10 >= 3 and $_[0] % 10 <= 4 || $_[0] % 10 == 9
!ll&&!rl&&r
213
$_[0] % 10 <= 4 or $_[0] % 10 == 9
l!l&&r!l&&!r
211
$_[0] % 100 < 10 or $_[0] % 100 > 19
l!l&&r!l&&!r
300
$_[0] % 100 < 70 or $_[0] % 100 > 79
l!l&&r!l&&!r
300
$_[0] % 100 < 90 or $_[0] % 100 > 99
l!l&&r!l&&!r
300
MC/DC40%4/10
int $_[0] == $_[0] && ($_[0] % 10 >= 3 && ($_[0] % 10 <= 4 || $_[0] % 10 == 9) && ($_[0] % 100 < 10 || $_[0] % 100 > 19) && ($_[0] % 100 < 70 || $_[0] % 100 > 79) && ($_[0] % 100 < 90 || $_[0] % 100 > 99))
int $_[0] == $_[0] $_[0] % 10 >= 3 $_[0] % 10 <= 4 $_[0] % 10 == 9 $_[0] % 100 < 10 $_[0] % 100 > 19 $_[0] % 100 < 70 $_[0] % 100 > 79 $_[0] % 100 < 90 $_[0] % 100 > 99
Truth table15%5/33
A && B and C or D and E or F and G or H and I or J
A= int $_[0] == $_[0]B= $_[0] % 10 >= 3C= $_[0] % 10 <= 4D= $_[0] % 10 == 9E= $_[0] % 100 < 10F= $_[0] % 100 > 19G= $_[0] % 100 < 70H= $_[0] % 100 > 79I= $_[0] % 100 < 90J= $_[0] % 100 > 99
ABCDEFGHIJresult
0XXXXXXXXX0
10XXXXXXXX0
1100XXXXXX0
111X00XXXX0
110100XXXX0
111X1X00XX0
111X0100XX0
11011X00XX0
11010100XX0
111X1X1X000
111X1X01000
111X011X000
111X0101000
11011X1X000
11011X01000
1101011X000
11010101000
111X1X1X1X1
111X1X1X011
111X1X011X1
111X1X01011
111X011X1X1
111X011X011
111X01011X1
111X0101011
11011X1X1X1
11011X1X011
11011X011X1
11011X01011
1101011X1X1
1101011X011
110101011X1
11010101011
2459 (
2460 (
2461 $_[0] % 10 >= 3 &&
2462 (
2463 $_[0] % 10 <= 4 ||
2464 $_[0] % 10 == 9
2465 )
2466 )
2467 &&
2468 (
2469 $_[0] % 100 < 10 ||
2470 $_[0] % 100 > 19
2471 )
2472 &&
2473 (
2474 $_[0] % 100 < 70 ||
2475 $_[0] % 100 > 79
2476 )
2477 &&
2478 (
2479 $_[0] % 100 < 90 ||
2480 $_[0] % 100 > 99
2481 )
2482 )
2483 },
2484 many => sub
2485 5 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.1
2486 5 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] != 0 and $_[0] % 1000000 == 0 3 2 5
Condition66%2/3
int $_[0] == $_[0] and $_[0] != 0
!ll&&!rl&&r
203
MC/DC50%1/2
int $_[0] == $_[0] and $_[0] != 0
int $_[0] == $_[0] $_[0] != 0
Truth table66%2/3
A and B
A= int $_[0] == $_[0]B= $_[0] != 0
ABresult
0X0
100
111
2487 $_[0] != 0 &&
2488 $_[0] % 1000000 == 0
2489 },
2490 4 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2491 },
2492 # mt
2493 mt =>
2494 {
2495 9 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 1 8 9
2496 8 ▶ two => sub { $_[0] == 2 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 2 and int $_[0] == $_[0] 1 7 8
2497 few => sub
2498 7 ▶ {
Subroutine __ANON__: called CC=4 SCAR=13.9
2499 7 ▶ $_[0] == 0 ||
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 0 or int $_[0] == $_[0] and $_[0] % 100 >= 3 and $_[0] % 100 <= 10 1 6 7
Condition88%8/9
$_[0] == 0 || int $_[0] == $_[0] && $_[0] % 100 >= 3 && $_[0] % 100 <= 10
l!l&&r!l&&!r
124
int $_[0] == $_[0] and $_[0] % 100 >= 3 and $_[0] % 100 <= 10
!ll&&!rl&&r
132
int $_[0] == $_[0] and $_[0] % 100 >= 3
!ll&&!rl&&r
105
MC/DC75%3/4
$_[0] == 0 || int $_[0] == $_[0] && $_[0] % 100 >= 3 && $_[0] % 100 <= 10
$_[0] == 0 int $_[0] == $_[0] $_[0] % 100 >= 3 $_[0] % 100 <= 10
Truth table80%4/5
A || B and C and D
A= $_[0] == 0B= int $_[0] == $_[0]C= $_[0] % 100 >= 3D= $_[0] % 100 <= 10
ABCDresult
1XXX1
01111
00XX0
010X0
01100
2500 (
2501 int( $_[0] ) == $_[0] &&
2502 $_[0] % 100 >= 3 &&
2503 $_[0] % 100 <= 10
2504 )
2505 },
2506 many => sub
2507 4 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.1
2508 4 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 >= 11 and $_[0] % 100 <= 19 3 1 4
Condition66%2/3
int $_[0] == $_[0] and $_[0] % 100 >= 11
!ll&&!rl&&r
103
MC/DC50%1/2
int $_[0] == $_[0] and $_[0] % 100 >= 11
int $_[0] == $_[0] $_[0] % 100 >= 11
Truth table66%2/3
A and B
A= int $_[0] == $_[0]B= $_[0] % 100 >= 11
ABresult
0X0
100
111
2509 $_[0] % 100 >= 11 &&
2510 $_[0] % 100 <= 19
2511 },
2512 2 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2513 },
2514 # ga
2515 ga =>
2516 {
2517 8 ▶ one => sub { $_[0] == 1 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 1 and int $_[0] == $_[0] 1 7 8
2518 7 ▶ two => sub { $_[0] == 2 && int( $_[0] ) == $_[0] },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] == 2 and int $_[0] == $_[0] 1 6 7
2519 few => sub
2520 6 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
2521 6 ▶ $_[0] >= 3 &&
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 3 and $_[0] <= 6 and int $_[0] == $_[0] 2 4 6
Condition100%3/3
$_[0] >= 3 and $_[0] <= 6
!ll&&!rl&&r
132
MC/DC100%2/2
$_[0] >= 3 and $_[0] <= 6
$_[0] >= 3 $_[0] <= 6
Truth table100%3/3
A and B
A= $_[0] >= 3B= $_[0] <= 6
ABresult
0X0
100
111
2522 $_[0] <= 6 &&
2523 int( $_[0] ) == $_[0]
2524 },
2525 many => sub
2526 4 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
2527 4 ▶ $_[0] >= 7 &&
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 7 and $_[0] <= 10 and int $_[0] == $_[0] 2 2 4
Condition100%3/3
$_[0] >= 7 and $_[0] <= 10
!ll&&!rl&&r
112
MC/DC100%2/2
$_[0] >= 7 and $_[0] <= 10
$_[0] >= 7 $_[0] <= 10
Truth table100%3/3
A and B
A= $_[0] >= 7B= $_[0] <= 10
ABresult
0X0
100
111
2528 $_[0] <= 10 &&
2529 int( $_[0] ) == $_[0]
2530 },
2531 2 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2532 },
2533 # gv
2534 gv =>
2535 {
2536 9 ▶ one => sub { int( $_[0] ) == $_[0] && $_[0] % 10 == 1 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 1 8 1 9
2537 7 ▶ two => sub { int( $_[0] ) == $_[0] && $_[0] % 10 == 2 },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 10 == 2 6 1 7
2538 few => sub
2539 5 ▶ {
Subroutine __ANON__: called CC=6 SCAR=18.0
2540 5 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 == 0 || $_[0] % 100 == 20 || $_[0] % 100 == 40 || $_[0] % 100 == 60 || $_[0] % 100 == 80 4 1 5
Condition86%13/15
int $_[0] == $_[0] && ($_[0] % 100 == 0 || $_[0] % 100 == 20 || $_[0] % 100 == 40 || $_[0] % 100 == 60 || $_[0] % 100 == 80)
!ll&&!rl&&r
113
$_[0] % 100 == 0 or $_[0] % 100 == 20 or $_[0] % 100 == 40 or $_[0] % 100 == 60 or $_[0] % 100 == 80
l!l&&r!l&&!r
301
$_[0] % 100 == 0 or $_[0] % 100 == 20 or $_[0] % 100 == 40 or $_[0] % 100 == 60
l!l&&r!l&&!r
301
$_[0] % 100 == 0 or $_[0] % 100 == 20 or $_[0] % 100 == 40
l!l&&r!l&&!r
211
$_[0] % 100 == 0 or $_[0] % 100 == 20
l!l&&r!l&&!r
112
MC/DC66%4/6
int $_[0] == $_[0] && ($_[0] % 100 == 0 || $_[0] % 100 == 20 || $_[0] % 100 == 40 || $_[0] % 100 == 60 || $_[0] % 100 == 80)
int $_[0] == $_[0] $_[0] % 100 == 0 $_[0] % 100 == 20 $_[0] % 100 == 40 $_[0] % 100 == 60 $_[0] % 100 == 80
Truth table71%5/7
A && B or C or D or E or F
A= int $_[0] == $_[0]B= $_[0] % 100 == 0C= $_[0] % 100 == 20D= $_[0] % 100 == 40E= $_[0] % 100 == 60F= $_[0] % 100 == 80
ABCDEFresult
0XXXXX0
1000000
11XXXX1
101XXX1
1001XX1
10001X1
1000011
2541 (
2542 $_[0] % 100 == 0 ||
2543 $_[0] % 100 == 20 ||
2544 $_[0] % 100 == 40 ||
2545 $_[0] % 100 == 60 ||
2546 $_[0] % 100 == 80
2547 )
2548 },
2549 2 ▶ many => sub { int( $_[0] ) != $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
2550 1 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2551 },
2552  
2553 # 6: zero, one, two, few, many, other
2554 # kw (Cornish)
2555 kw =>
2556 {
2557 9 ▶ zero => sub { $_[0] == 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2558 8 ▶ one => sub { $_[0] == 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2559 two => sub
2560 7 ▶ {
Subroutine __ANON__: called CC=14 SCAR=34.7
2561 7 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] == 2 || ($_[0] % 100 == 22 || $_[0] % 100 == 42 || $_[0] % 100 == 62 || $_[0] % 100 == 82 || $_[0] % 1000 == 0 && ($_[0] % 100000 >= 1000 && $_[0] % 100000 <= 20000) || ($_[0] % 100000 == 40000 || $_[0] % 100000 == 60000 || $_[0] % 100000 == 80000) || $_[0] % 1000000 == 100000 && $_[0] != 0) 6 1 7
Condition51%20/39
int $_[0] == $_[0] && ($_[0] == 2 || ($_[0] % 100 == 22 || $_[0] % 100 == 42 || $_[0] % 100 == 62 || $_[0] % 100 == 82 || $_[0] % 1000 == 0 && ($_[0] % 100000 >= 1000 && $_[0] % 100000 <= 20000) || ($_[0] % 100000 == 40000 || $_[0] % 100000 == 60000 || $_[0] % 100000 == 80000) || $_[0] % 1000000 == 100000 && $_[0] != 0))
!ll&&!rl&&r
142
$_[0] == 2 or ($_[0] % 100 == 22 or $_[0] % 100 == 42 or $_[0] % 100 == 62 or $_[0] % 100 == 82 or $_[0] % 1000 == 0 and ($_[0] % 100000 >= 1000 and $_[0] % 100000 <= 20000) or ($_[0] % 100000 == 40000 or $_[0] % 100000 == 60000 or $_[0] % 100000 == 80000) or $_[0] % 1000000 == 100000 and $_[0] != 0)
l!l&&r!l&&!r
114
$_[0] % 100 == 22 or $_[0] % 100 == 42 or $_[0] % 100 == 62 or $_[0] % 100 == 82 or $_[0] % 1000 == 0 and ($_[0] % 100000 >= 1000 and $_[0] % 100000 <= 20000) or ($_[0] % 100000 == 40000 or $_[0] % 100000 == 60000 or $_[0] % 100000 == 80000) or $_[0] % 1000000 == 100000 and $_[0] != 0
l!l&&r!l&&!r
014
$_[0] % 100 == 22 or $_[0] % 100 == 42 or $_[0] % 100 == 62 or $_[0] % 100 == 82 or $_[0] % 1000 == 0 and ($_[0] % 100000 >= 1000 and $_[0] % 100000 <= 20000) or ($_[0] % 100000 == 40000 or $_[0] % 100000 == 60000 or $_[0] % 100000 == 80000)
l!l&&r!l&&!r
005
$_[0] % 100 == 22 or $_[0] % 100 == 42 or $_[0] % 100 == 62 or $_[0] % 100 == 82 or $_[0] % 1000 == 0 and ($_[0] % 100000 >= 1000 and $_[0] % 100000 <= 20000)
l!l&&r!l&&!r
005
$_[0] % 100 == 22 or $_[0] % 100 == 42 or $_[0] % 100 == 62 or $_[0] % 100 == 82
l!l&&r!l&&!r
005
$_[0] % 100 == 22 or $_[0] % 100 == 42 or $_[0] % 100 == 62
l!l&&r!l&&!r
005
$_[0] % 100 == 22 or $_[0] % 100 == 42
l!l&&r!l&&!r
005
$_[0] % 1000 == 0 and ($_[0] % 100000 >= 1000 and $_[0] % 100000 <= 20000)
!ll&&!rl&&r
410
$_[0] % 100000 >= 1000 and $_[0] % 100000 <= 20000
!ll&&!rl&&r
100
$_[0] % 100000 == 40000 or $_[0] % 100000 == 60000 or $_[0] % 100000 == 80000
l!l&&r!l&&!r
005
$_[0] % 100000 == 40000 or $_[0] % 100000 == 60000
l!l&&r!l&&!r
005
$_[0] % 1000000 == 100000 and $_[0] != 0
!ll&&!rl&&r
401
MC/DC14%2/14
int $_[0] == $_[0] && ($_[0] == 2 || ($_[0] % 100 == 22 || $_[0] % 100 == 42 || $_[0] % 100 == 62 || $_[0] % 100 == 82 || $_[0] % 1000 == 0 && ($_[0] % 100000 >= 1000 && $_[0] % 100000 <= 20000) || ($_[0] % 100000 == 40000 || $_[0] % 100000 == 60000 || $_[0] % 100000 == 80000) || $_[0] % 1000000 == 100000 && $_[0] != 0))
int $_[0] == $_[0] $_[0] == 2 $_[0] % 100 == 22 $_[0] % 100 == 42 $_[0] % 100 == 62 $_[0] % 100 == 82 $_[0] % 1000 == 0 $_[0] % 100000 >= 1000 $_[0] % 100000 <= 20000 $_[0] % 100000 == 40000 $_[0] % 100000 == 60000 $_[0] % 100000 == 80000 $_[0] % 1000000 == 100000 $_[0] != 0
Truth table16%4/25
A && B or C or D or E or F or G and H and I or J or K or L or M and N
A= int $_[0] == $_[0]B= $_[0] == 2C= $_[0] % 100 == 22D= $_[0] % 100 == 42E= $_[0] % 100 == 62F= $_[0] % 100 == 82G= $_[0] % 1000 == 0H= $_[0] % 100000 >= 1000I= $_[0] % 100000 <= 20000J= $_[0] % 100000 == 40000K= $_[0] % 100000 == 60000L= $_[0] % 100000 == 80000M= $_[0] % 1000000 == 100000N= $_[0] != 0
ABCDEFGHIJKLMNresult
0XXXXXXXXXXXXX0
1000000XX0000X0
1000000XX000100
10000010X0000X0
10000010X000100
1000001100000X0
100000110000100
11XXXXXXXXXXXX1
101XXXXXXXXXXX1
1001XXXXXXXXXX1
10001XXXXXXXXX1
100001XXXXXXXX1
100000111XXXXX1
1000000XX1XXXX1
1000000XX01XXX1
1000000XX001XX1
10000010X1XXXX1
10000010X01XXX1
10000010X001XX1
1000001101XXXX1
10000011001XXX1
100000110001XX1
1000000XX000111
10000010X000111
100000110000111
2562 (
2563 # Directly include 2
2564 $_[0] == 2
2565 ||
2566 # Existing conditions for other cases
2567 (
2568 (
2569 $_[0] % 100 == 22 ||
2570 $_[0] % 100 == 42 ||
2571 $_[0] % 100 == 62 ||
2572 $_[0] % 100 == 82
2573 )
2574 ||
2575 (
2576 $_[0] % 1000 == 0 &&
2577 (
2578 $_[0] % 100000 >= 1000 &&
2579 $_[0] % 100000 <= 20000
2580 )
2581 )
2582 ||
2583 (
2584 $_[0] % 100000 == 40000 ||
2585 $_[0] % 100000 == 60000 ||
2586 $_[0] % 100000 == 80000
2587 )
2588 ||
2589 (
2590 $_[0] % 1000000 == 100000 &&
2591 $_[0] != 0
2592 )
2593 )
2594 )
2595 },
2596 few => sub
2597 5 ▶ {
Subroutine __ANON__: called CC=6 SCAR=18.2
2598 5 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 == 3 || $_[0] % 100 == 23 || $_[0] % 100 == 43 || $_[0] % 100 == 63 || $_[0] % 100 == 83 4 1 5
Condition80%12/15
int $_[0] == $_[0] && ($_[0] % 100 == 3 || $_[0] % 100 == 23 || $_[0] % 100 == 43 || $_[0] % 100 == 63 || $_[0] % 100 == 83)
!ll&&!rl&&r
122
$_[0] % 100 == 3 or $_[0] % 100 == 23 or $_[0] % 100 == 43 or $_[0] % 100 == 63 or $_[0] % 100 == 83
l!l&&r!l&&!r
112
$_[0] % 100 == 3 or $_[0] % 100 == 23 or $_[0] % 100 == 43 or $_[0] % 100 == 63
l!l&&r!l&&!r
103
$_[0] % 100 == 3 or $_[0] % 100 == 23 or $_[0] % 100 == 43
l!l&&r!l&&!r
103
$_[0] % 100 == 3 or $_[0] % 100 == 23
l!l&&r!l&&!r
103
MC/DC50%3/6
int $_[0] == $_[0] && ($_[0] % 100 == 3 || $_[0] % 100 == 23 || $_[0] % 100 == 43 || $_[0] % 100 == 63 || $_[0] % 100 == 83)
int $_[0] == $_[0] $_[0] % 100 == 3 $_[0] % 100 == 23 $_[0] % 100 == 43 $_[0] % 100 == 63 $_[0] % 100 == 83
Truth table57%4/7
A && B or C or D or E or F
A= int $_[0] == $_[0]B= $_[0] % 100 == 3C= $_[0] % 100 == 23D= $_[0] % 100 == 43E= $_[0] % 100 == 63F= $_[0] % 100 == 83
ABCDEFresult
0XXXXX0
1000000
11XXXX1
101XXX1
1001XX1
10001X1
1000011
2599 (
2600 $_[0] % 100 == 3 ||
2601 $_[0] % 100 == 23 ||
2602 $_[0] % 100 == 43 ||
2603 $_[0] % 100 == 63 ||
2604 $_[0] % 100 == 83
2605 )
2606 },
2607 many => sub
2608 3 ▶ {
Subroutine __ANON__: called CC=7 SCAR=20.4
2609 3 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] != 1 and $_[0] % 100 == 1 || $_[0] % 100 == 21 || $_[0] % 100 == 41 || $_[0] % 100 == 61 || $_[0] % 100 == 81 2 1 3
Condition72%13/18
int $_[0] == $_[0] && $_[0] != 1 && ($_[0] % 100 == 1 || $_[0] % 100 == 21 || $_[0] % 100 == 41 || $_[0] % 100 == 61 || $_[0] % 100 == 81)
!ll&&!rl&&r
111
int $_[0] == $_[0] and $_[0] != 1
!ll&&!rl&&r
102
$_[0] % 100 == 1 or $_[0] % 100 == 21 or $_[0] % 100 == 41 or $_[0] % 100 == 61 or $_[0] % 100 == 81
l!l&&r!l&&!r
101
$_[0] % 100 == 1 or $_[0] % 100 == 21 or $_[0] % 100 == 41 or $_[0] % 100 == 61
l!l&&r!l&&!r
101
$_[0] % 100 == 1 or $_[0] % 100 == 21 or $_[0] % 100 == 41
l!l&&r!l&&!r
101
$_[0] % 100 == 1 or $_[0] % 100 == 21
l!l&&r!l&&!r
011
MC/DC28%2/7
int $_[0] == $_[0] && $_[0] != 1 && ($_[0] % 100 == 1 || $_[0] % 100 == 21 || $_[0] % 100 == 41 || $_[0] % 100 == 61 || $_[0] % 100 == 81)
int $_[0] == $_[0] $_[0] != 1 $_[0] % 100 == 1 $_[0] % 100 == 21 $_[0] % 100 == 41 $_[0] % 100 == 61 $_[0] % 100 == 81
Truth table37%3/8
A and B && C or D or E or F or G
A= int $_[0] == $_[0]B= $_[0] != 1C= $_[0] % 100 == 1D= $_[0] % 100 == 21E= $_[0] % 100 == 41F= $_[0] % 100 == 61G= $_[0] % 100 == 81
ABCDEFGresult
0XXXXXX0
10XXXXX0
11000000
111XXXX1
1101XXX1
11001XX1
110001X1
11000011
2610 $_[0] != 1 &&
2611 (
2612 $_[0] % 100 == 1 ||
2613 $_[0] % 100 == 21 ||
2614 $_[0] % 100 == 41 ||
2615 $_[0] % 100 == 61 ||
2616 $_[0] % 100 == 81
2617 )
2618 },
2619 2 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2620 },
2621 # ar ars
2622 ar =>
2623 {
2624 10 ▶ zero => sub { $_[0] == 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2625 9 ▶ one => sub { $_[0] == 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2626 8 ▶ two => sub { $_[0] == 2 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2627 few => sub
2628 7 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
2629 7 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 >= 3 and $_[0] % 100 <= 10 4 3 7
Condition100%3/3
int $_[0] == $_[0] and $_[0] % 100 >= 3
!ll&&!rl&&r
214
MC/DC100%2/2
int $_[0] == $_[0] and $_[0] % 100 >= 3
int $_[0] == $_[0] $_[0] % 100 >= 3
Truth table100%3/3
A and B
A= int $_[0] == $_[0]B= $_[0] % 100 >= 3
ABresult
0X0
100
111
2630 $_[0] % 100 >= 3 &&
2631 $_[0] % 100 <= 10
2632 },
2633 many => sub
2634 5 ▶ {
Subroutine __ANON__: called CC=3 SCAR=11.0
2635 5 ▶ int( $_[0] ) == $_[0] &&
Branch: 1 branch
BranchTrueFalseTotal
int $_[0] == $_[0] and $_[0] % 100 >= 11 and $_[0] % 100 <= 99 2 3 5
Condition100%3/3
int $_[0] == $_[0] and $_[0] % 100 >= 11
!ll&&!rl&&r
212
MC/DC100%2/2
int $_[0] == $_[0] and $_[0] % 100 >= 11
int $_[0] == $_[0] $_[0] % 100 >= 11
Truth table100%3/3
A and B
A= int $_[0] == $_[0]B= $_[0] % 100 >= 11
ABresult
0X0
100
111
2636 $_[0] % 100 >= 11 &&
2637 $_[0] % 100 <= 99
2638 },
2639 3 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2640 },
2641 # The other locales in this group are aliased
2642  
2643 # cy
2644 cy =>
2645 {
2646 9 ▶ zero => sub { $_[0] == 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2647 8 ▶ one => sub { $_[0] == 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2648 7 ▶ two => sub { $_[0] == 2 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2649 6 ▶ few => sub { $_[0] == 3 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2650 5 ▶ many => sub { $_[0] == 6 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2651 4 ▶ other => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
2652 },
2653 7 };
2654  
2655 # NOTE: Aliasing for plural forms
2656 7 my $aliases =
2657 {
2658 # 1: other
2659 bm => [qw( bo dz hnj id ig ii in ja jbo jv jw kde kea km ko lkt lo ms my nqo osa root sah ses sg su th to tpi vi wo yo yue zh )],
2660 # 2: one, other
2661 am => [qw( as bn doi fa gu hi kn pcm zu )],
2662 ff => [qw( hy kab )],
2663 ast => [qw( de en et fi fy gl ia io ji lij nl sc sv sw ur yi )],
2664 ak => [qw( bho csw guw ln mg nso pa ti wa )],
2665 af => [qw( an asa az bal bem bez bg brx ce cgg chr ckb dv ee el eo eu fo fur gsw ha haw hu jgo jmc ka kaj kcg kk kkj kl ks ksb ku ky lb lg mas mgo ml mn mr nah nb nd ne nn nnh no nr ny nyn om or os pap ps rm rof rwk saq sd sdh seh sn so sq ss ssy st syr
2666 ta te teo tig tk tn tr ts ug uz ve vo vun wae xh xog )],
2667 ceb => [qw( fil tl )],
2668  
2669 # 3: zero,one,other
2670 lv => [qw( prg )],
2671  
2672 # 3: one,two,other
2673 he => [qw( iw )],
2674 iu => [qw( naq sat se sma smi smj smn sms )],
2675  
2676 # 3: one,few,other
2677 mo => [qw( ro )],
2678 bs => [qw( hr sh sr )],
2679  
2680 # 3: one,many,other
2681 ca => [qw( it lld pt-PT scn vec )],
2682  
2683 # 4: one,two,few,other
2684 dsb => [qw( hsb )],
2685  
2686 # 4: one,few,many,other
2687 cs => [qw( sk )],
2688 ru => [qw( uk )],
2689  
2690 # 5: one,two,few,many,other
2691 # No aliases in this group
2692  
2693 # 6: zero,one,two,few,many,other
2694 ar => [qw( ars )],
2695 };
2696  
2697 7 foreach my $locale ( keys( %$aliases ) )
2698 {
2699 119 $plural_rules->{ $_ } = $plural_rules->{ $locale } for( @{$aliases->{ $locale }} );
2700 }
2701  
2702 # https://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules
2703 # https://cldr.unicode.org/index/cldr-spec/plural-rules
2704 # https://unicode.org/reports/tr35/tr35-dates.html#Contents
2705 sub plural_count
2706 246 ▶{
Subroutine plural_count: called CC=12 SCAR=27.7
Pod documented
2707 246 my $self = shift( @_ );
2708 246 my $number = shift( @_ );
2709 246 my $locale = shift( @_ );
2710 246 ▶ if( !length( $number // '' ) )
Branch: 2 branches
BranchTrueFalseTotal
if (not length($number // '')) { } 0 246 246
elsif (not length $locale) { } 0 246 246
Condition50%1/2
$number // ""
l!l
2460
MC/DC0%0/1
$number // ""
$number
Truth table50%1/2
A
A= $number
Aresult
11
00
2711 {
2712 0 return( $self->error( "No number was provided to get its plural count." ) );
2713 }
2714 elsif( !length( $locale ) )
2715 {
2716 0 return( $self->error( "No locale was provided to get its plural count." ) );
2717 }
2718 246 ▶ $locale = $self->_locale_object( $locale ) ||
Condition50%1/2
$self->_locale_object($locale) || (return $self->pass_error)
l!l
2460
MC/DC0%0/1
$self->_locale_object($locale) || (return $self->pass_error)
$self->_locale_object($locale)
Truth table50%1/2
A
A= $self->_locale_object($locale)
Aresult
11
00
2719 return( $self->pass_error );
2720  
2721 246 my $rules;
2722 246 ▶ my $tree = $self->make_inheritance_tree( $locale->base ) ||
Condition50%1/2
$self->make_inheritance_tree($locale->base) || (return $self->pass_error)
l!l
2460
MC/DC0%0/1
$self->make_inheritance_tree($locale->base) || (return $self->pass_error)
$self->make_inheritance_tree($locale->base)
Truth table50%1/2
A
A= $self->make_inheritance_tree($locale->base)
Aresult
11
00
2723 return( $self->pass_error );
2724 246 foreach my $loc ( @$tree )
2725 {
2726 246 ▶ if( exists( $plural_rules->{ $loc } ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $plural_rules->{$loc}) 246 0 246
2727 {
2728 246 $rules = $plural_rules->{ $loc };
2729 246 last;
2730 }
2731 }
2732 # I could also write it as $rules //= { one => sub { $_[0] == 1 }, other => sub { 1 } };
2733 # but I would lose point for readability
2734 246 ▶ if( !defined( $rules ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rules) 0 246 246
2735 {
2736 0 ▶ $rules = { one => sub { $_[0] == 1 }, other => sub { 1 } };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
2737 }
2738 246 foreach my $category ( qw( zero one two few many other ) )
2739 {
2740 953 ▶ if( exists( $rules->{ $category } ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rules->{$category} and $rules->{$category}->($number)) 245 708 953
Condition100%3/3
exists $rules->{$category} and $rules->{$category}->($number)
!ll&&!rl&&r
372336245
MC/DC100%2/2
exists $rules->{$category} and $rules->{$category}->($number)
exists $rules->{$category} $rules->{$category}->($number)
Truth table100%3/3
A and B
A= exists $rules->{$category}B= $rules->{$category}->($number)
ABresult
0X0
100
111
2741 $rules->{ $category }->( $number ) )
2742 {
2743 245 return( $category );
2744 }
2745 }
2746 # It should never reach here
2747 1 return( 'other' );
2748 }
2749  
2750 # The hash reference containing the core 40 locales on which all the other 182, out of 222 locales, are aliases.
2751 7 my $plural_forms;
2752 sub plural_forms
2753 222 ▶{
Subroutine plural_forms: called CC=16 SCAR=31.3
Pod documented
2754 222 my $self = shift( @_ );
2755 222 ▶ my $locale = shift( @_ ) ||
Condition50%1/2
shift @_ || (return $self->error('No locale has been provided to retrieve its Gettext plural forms.'))
l!l
2220
MC/DC0%0/1
shift @_ || (return $self->error('No locale has been provided to retrieve its Gettext plural forms.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
2756 return( $self->error( "No locale has been provided to retrieve its Gettext plural forms." ) );
2757 # This is designed to minimise memory consumption.
2758 # Also, the list is pre-built in advance. Given it contains only 40 locales, it has a high effort-merit ratio and saves CPU.
2759 # So, no need to dynamically convert CLDR plural rules into its Gettext plural forms equivalent.
2760 # If our dictionary is not yet defined, we create it now.
2761 222 ▶ unless( defined( $plural_forms ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $plural_forms) 1 221 222
2762 {
2763 1 my $plural_forms_data = <<'EOT';
2764 $plural_forms =
2765 {
2766 af => "nplurals=2; plural=(n != 1);",
2767 ak => "nplurals=2; plural=(n > 1);",
2768 am => "nplurals=2; plural=(n > 1);",
2769 ar => "nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5);",
2770 ast => "nplurals=2; plural=(n != 1);",
2771 be => "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
2772 blo => "nplurals=3; plural=(n==0 ? 0 : n==1 ? 1 : 2);",
2773 bm => "nplurals=1; plural=0;",
2774 br => "nplurals=5; plural=(n%10==1 && !(n%100==11||n%100==71||n%100==91) ? 0 : n%10==2 && !(n%100==12||n%100==72||n%100==92) ? 1 : (n%10==3||n%10==4||n%10==9) && !(n%100>=10&&n%100<=19||n%100>=70&&n%100<=79||n%100>=90&&n%100<=99) ? 2 : n!=0&&n%1000000==0 ? 3 : 4);",
2775 bs => "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
2776 ca => "nplurals=2; plural=(n != 1);",
2777 ceb => "nplurals=2; plural=(n > 1);",
2778 cs => "nplurals=3; plural=(n==1 ? 0 : n>=2 && n<=4 ? 1 : 2);",
2779 cy => "nplurals=4; plural=(n==1 ? 0 : n==2 ? 1 : n!=8 && n!=11 ? 2 : 3);",
2780 da => "nplurals=2; plural=(n != 1);",
2781 dsb => "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);",
2782 es => "nplurals=2; plural=(n != 1);",
2783 ff => "nplurals=2; plural=(n != 1);",
2784 fr => "nplurals=2; plural=(n > 1);",
2785 ga => "nplurals=5; plural=(n==1 ? 0 : n==2 ? 1 : n>2 && n<7 ? 2 : n>6 && n<11 ? 3 : 4);",
2786 gd => "nplurals=4; plural=(n==1 || n==11 ? 0 : n==2 || n==12 ? 1 : n>2 && n<20 ? 2 : 3);",
2787 gv => "nplurals=2; plural=(n > 1);",
2788 he => "nplurals=2; plural=(n != 1);",
2789 is => "nplurals=2; plural=(n%10!=1 || n%100==11);",
2790 iu => "nplurals=3; plural=(n==1 ? 0 : n==2 ? 1 : 2);",
2791 ksh => "nplurals=3; plural=(n==0 ? 0 : n==1 ? 1 : 2);",
2792 kw => "nplurals=4; plural=(n==1 ? 0 : n==2 ? 1 : n==3 ? 2 : 3);",
2793 lag => "nplurals=3; plural=(n==0 ? 0 : n==1 ? 1 : 2);",
2794 lt => "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);",
2795 lv => "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n!=0 ? 1 : 2);",
2796 mk => "nplurals=2; plural=(n==1 || n%10==1 ? 0 : 1);",
2797 mo => "nplurals=3; plural=(n==1 ? 0 : n==0 || (n%100>0 && n%100<20) ? 1 : 2);",
2798 mt => "nplurals=4; plural=(n==1 ? 0 : n==0 || (n%100>1 && n%100<11) ? 1 : n%100>10 && n%100<20 ? 2 : 3);",
2799 pl => "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
2800 pt => "nplurals=2; plural=(n != 1);",
2801 ru => "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
2802 shi => "nplurals=3; plural=(n==0 || n==1 ? 0 : n>=2 && n<=10 ? 1 : 2);",
2803 si => "nplurals=2; plural=(n != 1);",
2804 sl => "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);",
2805 tzm => "nplurals=2; plural=(n != 1);",
2806 };
2807 EOT
2808 1 local $@;
2809 1 eval( $plural_forms_data );
2810 1 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
2811 {
2812 0 return( $self->error( "Error evaluating the list of 40 core Gettext plural rules: $@" ) );
2813 }
2814 }
2815  
2816 222 ▶ if( exists( $plural_forms->{ $locale } ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $plural_forms->{$locale}) { } 40 182 222
2817 {
2818 40 return( $plural_forms->{ $locale } );
2819 }
2820 else
2821 {
2822 182 ▶ $locale = $self->_locale_object( $locale ) ||
Condition50%1/2
$self->_locale_object($locale) || (return $self->pass_error)
l!l
1820
MC/DC0%0/1
$self->_locale_object($locale) || (return $self->pass_error)
$self->_locale_object($locale)
Truth table50%1/2
A
A= $self->_locale_object($locale)
Aresult
11
00
2823 return( $self->pass_error );
2824  
2825 182 ▶ my $tree = $self->make_inheritance_tree( $locale->base ) ||
Condition50%1/2
$self->make_inheritance_tree($locale->base) || (return $self->pass_error)
l!l
1820
MC/DC0%0/1
$self->make_inheritance_tree($locale->base) || (return $self->pass_error)
$self->make_inheritance_tree($locale->base)
Truth table50%1/2
A
A= $self->make_inheritance_tree($locale->base)
Aresult
11
00
2826 return( $self->pass_error );
2827 182 foreach my $loc ( @$tree )
2828 {
2829 182 ▶ if( exists( $plural_forms->{ $loc } ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $plural_forms->{$loc}) 0 182 182
2830 {
2831 0 return( $plural_forms->{ $loc } );
2832 }
2833 # It is actually the 'aliases' property we are after, so we know which one of the core 40 we should be using.
2834 182 ▶ my $all = $self->plural_rules( locale => $loc ) ||
Condition50%1/2
$self->plural_rules('locale', $loc) || (return $self->pass_error)
l!l
1820
MC/DC0%0/1
$self->plural_rules('locale', $loc) || (return $self->pass_error)
$self->plural_rules('locale', $loc)
Truth table50%1/2
A
A= $self->plural_rules('locale', $loc)
Aresult
11
00
2835 return( $self->pass_error );
2836 182 ▶ if( $all && scalar( @$all ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($all and scalar @$all) 182 0 182
Condition50%1/2
$all and scalar @$all
!ll
0182
MC/DC0%0/1
$all and scalar @$all
$all
Truth table50%1/2
A
A= $all
Aresult
00
11
2837 {
2838 182 ▶ if( $all->[0]->{aliases} && ref( $all->[0]->{aliases} ) eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if ($all->[0]{"aliases"} and ref $all->[0]{"aliases"} eq "ARRAY") 182 0 182
Condition33%1/3
$all->[0]{"aliases"} and ref $all->[0]{"aliases"} eq "ARRAY"
!ll&&!rl&&r
00182
MC/DC0%0/2
$all->[0]{"aliases"} and ref $all->[0]{"aliases"} eq "ARRAY"
$all->[0]{"aliases"} ref $all->[0]{"aliases"} eq "ARRAY"
Truth table33%1/3
A and B
A= $all->[0]{"aliases"}B= ref $all->[0]{"aliases"} eq "ARRAY"
ABresult
0X0
100
111
2839 {
2840 182 foreach my $l ( @{$all->[0]->{aliases}} )
2841 {
2842 182 ▶ if( exists( $plural_forms->{ $l } ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $plural_forms->{$l}) 182 0 182
2843 {
2844 182 return( $plural_forms->{ $l } );
2845 }
2846 }
2847 }
2848 }
2849 }
2850 # Nothing found.
2851 0 return( '' );
2852 }
2853 }
2854  
2855 0 ▶sub plural_range { return( shift->_fetch_one({
Subroutine plural_range: not called CC=1 SCAR=6.9
Pod documented
2856 0 id => 'get_plural_range',
2857 field => 'result',
2858 has_array => [qw( aliases )],
2859 table => 'plural_ranges',
2860 requires => [qw( locale start stop )],
2861 default => { alt => undef },
2862 }, @_ ) ); }
2863  
2864 0 ▶sub plural_ranges { return( shift->_fetch_all({
Subroutine plural_ranges: not called CC=1 SCAR=6.9
Pod documented
2865 0 id => 'plural_ranges',
2866 has_array => [qw( aliases )],
2867 table => 'plural_ranges',
2868 by => [qw( locale aliases start stop result )],
2869 }, @_ ) ); }
2870  
2871 0 ▶sub plural_rule { return( shift->_fetch_one({
Subroutine plural_rule: not called CC=1 SCAR=6.9
Pod documented
2872 0 id => 'get_plural_rule',
2873 field => 'locale',
2874 has_array => [qw( aliases )],
2875 table => 'plural_rules',
2876 requires => [qw( locale )],
2877 }, @_ ) ); }
2878  
2879 182 ▶sub plural_rules { return( shift->_fetch_all({
Subroutine plural_rules: called CC=1 SCAR=0.0
Pod documented
2880 182 id => 'plural_rules',
2881 has_array => [qw( aliases )],
2882 table => 'plural_rules',
2883 by => [qw( locale aliases count rule )],
2884 }, @_ ) ); }
2885  
2886 1 ▶sub rbnf { return( shift->_fetch_one({
Subroutine rbnf: called CC=1 SCAR=0.0
Pod documented
2887 1 id => 'get_rbnf',
2888 field => 'rule_id',
2889 table => 'rbnf',
2890 requires => [qw( locale ruleset )],
2891 }, @_ ) ); }
2892  
2893 3 ▶sub rbnfs { return( shift->_fetch_all({
Subroutine rbnfs: called CC=1 SCAR=0.0
Pod documented
2894 3 id => 'rbnf',
2895 table => 'rbnf',
2896 by => [qw( locale grouping ruleset )],
2897 }, @_ ) ); }
2898  
2899 1 ▶sub reference { return( shift->_fetch_one({
Subroutine reference: called CC=1 SCAR=0.0
Pod documented
2900 1 id => 'get_ref',
2901 field => 'code',
2902 table => 'refs',
2903 }, @_ ) ); }
2904  
2905 0 ▶sub references { return( shift->_fetch_all({
Subroutine references: not called CC=1 SCAR=6.9
Pod documented
2906 0 id => 'refs',
2907 table => 'refs',
2908 }, @_ ) ); }
2909  
2910 # Retrieves data with the method given (for example calendar_terms()), following locale
2911 # inheritance. When nothing is found in the locale or its parents other than root, the
2912 # aliases stored in data_aliases are applied, as UTS #35 specifies for source="locale"
2913 # aliases: the lookup is restarted from the requested locale with the alias target.
2914 # Root is looked up last.
2915 # <https://www.unicode.org/reports/tr35/#Alias_Elements>
2916 sub resolve
2917 9 ▶{
Subroutine resolve: called CC=16 SCAR=28.2
Pod documented
2918 9 my $self = shift( @_ );
2919 9 ▶ my $meth = shift( @_ ) ||
Condition50%1/2
shift @_ || (return $self->error('No method was provided to resolve data.'))
l!l
90
MC/DC0%0/1
shift @_ || (return $self->error('No method was provided to resolve data.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
2920 return( $self->error( "No method was provided to resolve data." ) );
2921 9 ▶ my $def = $RESOLVABLE->{ $meth } ||
Condition100%2/2
$Locale::Unicode::Data::RESOLVABLE->{$meth} || (return $self->error("The method '${meth}' does not support data resolution."))
l!l
81
MC/DC100%1/1
$Locale::Unicode::Data::RESOLVABLE->{$meth} || (return $self->error("The method '${meth}' does not support data resolution."))
$Locale::Unicode::Data::RESOLVABLE->{$meth}
Truth table100%2/2
A
A= $Locale::Unicode::Data::RESOLVABLE->{$meth}
Aresult
11
00
2922 return( $self->error( "The method '${meth}' does not support data resolution." ) );
2923 8 my $opts = $self->_get_args_as_hash( @_ );
2924 8 my $locale = CORE::delete( $opts->{locale} );
2925 8 ▶ return( $self->error( "No locale was provided to resolve data with ${meth}()" ) ) if( !defined( $locale ) || !CORE::length( "$locale" ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $locale and length "$locale" 1 7 8
Condition66%2/3
defined $locale and length "$locale"
!ll&&!rl&&r
107
MC/DC50%1/2
defined $locale and length "$locale"
defined $locale length "$locale"
Truth table66%2/3
A and B
A= defined $localeB= length "$locale"
ABresult
0X0
100
111
2926 7 ▶ my $tree = $self->make_inheritance_tree( $locale ) || return( $self->pass_error );
Condition50%1/2
$self->make_inheritance_tree($locale) || (return $self->pass_error)
l!l
70
MC/DC0%0/1
$self->make_inheritance_tree($locale) || (return $self->pass_error)
$self->make_inheritance_tree($locale)
Truth table50%1/2
A
A= $self->make_inheritance_tree($locale)
Aresult
11
00
2927 7 ▶ my $rules = $self->_data_alias_rules( $def->{table} ) || return( $self->pass_error );
Condition50%1/2
$self->_data_alias_rules($def->{'table'}) || (return $self->pass_error)
l!l
70
MC/DC0%0/1
$self->_data_alias_rules($def->{'table'}) || (return $self->pass_error)
$self->_data_alias_rules($def->{'table'})
Truth table50%1/2
A
A= $self->_data_alias_rules($def->{'table'})
Aresult
11
00
2928 7 my $j = JSON->new->canonical->allow_nonref;
2929 7 my $keys = { %$opts };
2930 7 my $seen = {};
2931 7 while(1)
2932 {
2933 12 my $sig = $j->encode( $keys );
2934 12 ▶ return( $self->error( "Circular data aliases found while resolving ${meth}() with ${sig}" ) ) if( $seen->{ $sig }++ );
Branch: 1 branch
BranchTrueFalseTotal
if $seen->{$sig}++ 0 12 12
2935 12 foreach my $loc ( @$tree )
2936 {
2937 19 ▶ next if( $loc eq 'und' );
Branch: 1 branch
BranchTrueFalseTotal
if $loc eq "und" 7 12 19
2938 12 my( $found, $res ) = $self->_resolve_fetch( $meth, $def, $keys, $loc );
2939 12 ▶ return( $self->pass_error ) if( !defined( $found ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $found 0 12 12
2940 12 ▶ return( $res ) if( $found );
Branch: 1 branch
BranchTrueFalseTotal
if $found 5 7 12
2941 }
2942 7 ▶ my $rule = $self->_data_alias_match( $rules, $keys, $tree ) || last;
Condition100%2/2
$self->_data_alias_match($rules, $keys, $tree) || (last)
l!l
52
MC/DC100%1/1
$self->_data_alias_match($rules, $keys, $tree) || (last)
$self->_data_alias_match($rules, $keys, $tree)
Truth table100%2/2
A
A= $self->_data_alias_match($rules, $keys, $tree)
Aresult
11
00
2943 5 $keys = { %$keys, %{$rule->{target}} };
2944 }
2945 2 my( $found, $res ) = $self->_resolve_fetch( $meth, $def, $keys, 'und' );
2946 2 ▶ return( $self->pass_error ) if( !defined( $found ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $found 0 2 2
2947 2 ▶ return( $res ) if( $found );
Branch: 1 branch
BranchTrueFalseTotal
if $found 0 2 2
2948 2 ▶ return( $def->{all} ? [] : undef );
Branch: 1 branch
BranchTrueFalseTotal
$def->{'all'} ? : 1 1 2
2949 }
2950  
2951 1 ▶sub script { return( shift->_fetch_one({
Subroutine script: called CC=1 SCAR=0.0
Pod documented
2952 1 id => 'get_script',
2953 field => 'script',
2954 table => 'scripts',
2955 }, @_ ) ); }
2956  
2957 3 ▶sub scripts { return( shift->_fetch_all({
Subroutine scripts: called CC=1 SCAR=0.0
Pod documented
2958 3 id => 'scripts',
2959 table => 'scripts',
2960 by => [qw( rtl origin_country likely_language )],
2961 has_status => 1,
2962 }, @_ ) ); }
2963  
2964 1 ▶sub script_l10n { return( shift->_fetch_one({
Subroutine script_l10n: called CC=1 SCAR=0.0
Pod documented
2965 1 id => 'get_script_l10n',
2966 field => 'script',
2967 table => 'scripts_l10n',
2968 requires => [qw( locale alt )],
2969 default => { alt => undef },
2970 }, @_ ) ); }
2971  
2972 2 ▶sub scripts_l10n { return( shift->_fetch_all({
Subroutine scripts_l10n: called CC=1 SCAR=0.0
Pod documented
2973 2 id => 'scripts_l10n',
2974 table => 'scripts_l10n',
2975 by => [qw( locale alt )],
2976 }, @_ ) ); }
2977  
2978 sub split_interval
2979 0 ▶{
Subroutine split_interval: not called CC=24 SCAR=64.0
Pod documented
2980 0 my $self = shift( @_ );
2981 0 my $opts = $self->_get_args_as_hash( @_ );
2982 my $greatest_diff = $opts->{greatest_diff} ||
2983 0 ▶ return( $self->error( "No 'greatest_diff' argument value was provided." ) );
Condition0%0/2
$opts->{'greatest_diff'} || (return $self->error(q[No 'greatest_diff' argument value was provided.]))
l!l
00
MC/DC0%0/1
$opts->{'greatest_diff'} || (return $self->error(q[No 'greatest_diff' argument value was provided.]))
$opts->{'greatest_diff'}
Truth table0%0/2
A
A= $opts->{'greatest_diff'}
Aresult
11
00
2984 my $pat = $opts->{pattern} ||
2985 0 ▶ return( $self->error( "No pattern was provided." ) );
Condition0%0/2
$opts->{'pattern'} || (return $self->error('No pattern was provided.'))
l!l
00
MC/DC0%0/1
$opts->{'pattern'} || (return $self->error('No pattern was provided.'))
$opts->{'pattern'}
Truth table0%0/2
A
A= $opts->{'pattern'}
Aresult
11
00
2986 # {0} – {1}
2987 0 ▶ if( $pat =~ /^(?<p1>\{\d\})(?<sep>[^\{]+)(?<p2>\{\d\})$/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($pat =~ /^(?<p1>\{\d\})(?<sep>[^\{]+)(?<p2>\{\d\})$/) 0 0 0
2988 {
2989 0 return( [ $+{p1}, $+{sep}, $+{p2} ] );
2990 }
2991 # First, remove the quoted literals from our string so they do not interfer
2992 0 my $literals = {};
2993 0 my $spaces = [];
2994 0 ▶ if( index( $pat, "'" ) != -1 )
Branch: 1 branch
BranchTrueFalseTotal
if (index($pat, "'") != -1) 0 0 0
2995 {
2996 0 my $n = 0;
2997 0 $pat =~ s{
2998 (?<!\')(\'(?:[^\']+(?!=\'))\')
2999 }
3000 {
3001 0 ▶ if( !exists( $literals->{ $1 } ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $literals->{$1}) 0 0 0
3002 {
3003 0 $literals->{ $1 } = ++$n;
3004 }
3005 0 $literals->{ $1 } . '__';
3006 }gexs;
3007 }
3008 0 $pat =~ s{
3009 ([[:blank:]\h]+)
3010 }
3011 {
3012 0 push( @$spaces, $1 );
3013 0 ' ';
3014 }gexs;
3015 0 my $len = length( $pat );
3016 0 my $matches = {};
3017 0 my( $part1, $part2, $sep );
3018 0 my $equivalent =
3019 {
3020 'L' => 'M',
3021 'LL' => 'MM',
3022 'LLL' => 'MMM',
3023 'LLLL' => 'MMMM',
3024 'LLLLL' => 'MMMMM',
3025 'LLLLLL' => 'MMMMMM',
3026 'M' => 'L',
3027 'MM' => 'LL',
3028 'MMM' => 'LLL',
3029 'MMMM' => 'LLLL',
3030 'MMMM' => 'LLLLL',
3031 'MMMMM' => 'LLLLLL',
3032 };
3033 0 ▶ OUTER: for( my $i = 0; $i < $len; $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 0 0 0
3034 {
3035 0 ▶ INNER: for( my $j = 1; $j < ( $len - $i ); $j++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $len - $i) 0 0 0
3036 {
3037 0 my $check = substr( $pat, $i, $j );
3038 0 ▶ next OUTER if( $check =~ /^[^a-zA-Z]$/ );
Branch: 1 branch
BranchTrueFalseTotal
if $check =~ /^[^a-zA-Z]$/ 0 0 0
3039 0 my $pos = index( $pat, $check, $i + length( $check ) );
3040 0 ▶ if( exists( $equivalent->{ $check } ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $equivalent->{$check} and $pos == -1) 0 0 0
Condition0%0/3
exists $equivalent->{$check} and $pos == -1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $equivalent->{$check} and $pos == -1
exists $equivalent->{$check} $pos == -1
Truth table0%0/3
A and B
A= exists $equivalent->{$check}B= $pos == -1
ABresult
0X0
100
111
3041 $pos == -1 )
3042 {
3043 0 $pos = index( $pat, $equivalent->{ $check }, $i + length( $equivalent->{ $check } ) );
3044 0 ▶ $check = $equivalent->{ $check } if( $pos != -1 );
Branch: 1 branch
BranchTrueFalseTotal
if $pos != -1 0 0 0
3045 }
3046 0 ▶ if( $pos != -1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($pos != -1) 0 0 0
3047 {
3048 0 $matches->{ substr( $pat, $pos, length( $check ) ) } = [$i, $pos];
3049 }
3050 }
3051 }
3052  
3053 0 ▶ if( !scalar( keys( %$matches ) ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar keys %$matches) 0 0 0
3054 {
3055 0 ▶ warn( "Failed to find the repeating field in pattern '${pat}'" ) if( warnings::enabled() );
Branch: 1 branch
BranchTrueFalseTotal
if warnings::enabled() 0 0 0
3056 0 return( [] );
3057 }
3058 0 my @bests = sort{ length( $b ) <=> length( $a ) } keys( %$matches );
3059 0 my $max_len = length( $bests[0] );
3060 0 my $best;
3061 0 ▶ if( scalar( @bests ) > 1 && length( $bests[1] ) == $max_len )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @bests > 1 and length $bests[1] == $max_len) { } 0 0 0
Condition0%0/3
scalar @bests > 1 and length $bests[1] == $max_len
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @bests > 1 and length $bests[1] == $max_len
scalar @bests > 1 length $bests[1] == $max_len
Truth table0%0/3
A and B
A= scalar @bests > 1B= length $bests[1] == $max_len
ABresult
0X0
100
111
3062 {
3063 0 my $found;
3064 0 foreach my $this ( @bests )
3065 {
3066 0 ▶ if( index( $this, $greatest_diff ) != -1 )
Branch: 1 branch
BranchTrueFalseTotal
if (index($this, $greatest_diff) != -1) 0 0 0
3067 {
3068 0 $found = $this;
3069 0 last;
3070 }
3071 }
3072  
3073 0 ▶ if( !defined( $found ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $found) { } 0 0 0
3074 {
3075 0 return( $self->error( "Found ", scalar( @bests ), " candidates, but none had the greatest difference field ${greatest_diff}" ) );
3076 }
3077 else
3078 {
3079 0 $best = $found;
3080 }
3081 }
3082 else
3083 {
3084 0 $best = $bests[0];
3085 }
3086 0 my( $start1, $start2 ) = @{$matches->{ $best }};
3087 0 $part1 = substr( $pat, 0, ( $start1 + length( $best ) ) );
3088 0 $part2 = substr( $pat, $start2 );
3089 0 $sep = substr( $pat, $start1 + length( $best ), ( $start2 - ( $start1 + length( $best ) ) ) );
3090  
3091 0 ▶ if( scalar( @$spaces ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$spaces) 0 0 0
3092 {
3093 0 my $c = 0;
3094 0 for( $part1, $sep, $part2 )
3095 {
3096 0 s/([[:blank:]\h]+)/$spaces->[$c++]/g;
3097 }
3098 }
3099  
3100 0 ▶ if( scalar( keys( %$literals ) ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %$literals) 0 0 0
3101 {
3102 0 my $vals = { map{ $literals->{ $_ } => $_ } keys( %$literals ) };
3103 0 for( $part1, $part2, $sep )
3104 {
3105 0 s/(\d+)__/$vals->{ $1 }/g;
3106 }
3107 }
3108  
3109 0 return( [ $part1, $sep, $part2, $best ] );
3110 }
3111  
3112 1 ▶sub subdivision { return( shift->_fetch_one({
Subroutine subdivision: called CC=1 SCAR=0.0
Pod documented
3113 1 id => 'get_subdivision',
3114 field => 'subdivision',
3115 table => 'subdivisions',
3116 }, @_ ) ); }
3117  
3118 3 ▶sub subdivisions { return( shift->_fetch_all({
Subroutine subdivisions: called CC=1 SCAR=0.0
Pod documented
3119 3 id => 'subdivisions',
3120 table => 'subdivisions',
3121 by => [qw( territory parent is_top_level )],
3122 has_status => 1,
3123 }, @_ ) ); }
3124  
3125 1 ▶sub subdivision_l10n { return( shift->_fetch_one({
Subroutine subdivision_l10n: called CC=1 SCAR=0.0
Pod documented
3126 1 id => 'get_subdivision_l10n',
3127 field => 'subdivision',
3128 table => 'subdivisions_l10n',
3129 requires => [qw( locale )],
3130 }, @_ ) ); }
3131  
3132 1 ▶sub subdivisions_l10n { return( shift->_fetch_all({
Subroutine subdivisions_l10n: called CC=1 SCAR=0.0
Pod documented
3133 1 id => 'subdivisions_l10n',
3134 table => 'subdivisions_l10n',
3135 by => [qw( locale )],
3136 }, @_ ) ); }
3137  
3138 1 ▶sub territory { return( shift->_fetch_one({
Subroutine territory: called CC=1 SCAR=0.0
Pod documented
3139 1 id => 'get_territory',
3140 field => 'territory',
3141 table => 'territories',
3142 has_array => [qw( languages contains calendars weekend )],
3143 }, @_ ) ); }
3144  
3145 1 ▶sub territories { return( shift->_fetch_all({
Subroutine territories: called CC=1 SCAR=0.0
Pod documented
3146 1 id => 'territories',
3147 table => 'territories',
3148 by => [qw( parent alt )],
3149 has_status => 1,
3150 has_array => [qw( languages contains calendars weekend )],
3151 }, @_ ) ); }
3152  
3153 1 ▶sub territory_l10n { return( shift->_fetch_one({
Subroutine territory_l10n: called CC=1 SCAR=0.0
Pod documented
3154 1 id => 'get_territory_l10n',
3155 field => 'territory',
3156 table => 'territories_l10n',
3157 requires => [qw( locale alt )],
3158 default => { alt => undef },
3159 }, @_ ) ); }
3160  
3161 2 ▶sub territories_l10n { return( shift->_fetch_all({
Subroutine territories_l10n: called CC=1 SCAR=0.0
Pod documented
3162 2 id => 'territories_l10n',
3163 table => 'territories_l10n',
3164 by => [qw( locale alt )],
3165 }, @_ ) ); }
3166  
3167 1 ▶sub time_format { return( shift->_fetch_one({
Subroutine time_format: called CC=1 SCAR=0.0
Pod documented
3168 1 id => 'get_time_format',
3169 field => 'region',
3170 table => 'time_formats',
3171 has_array => [qw( time_allowed )],
3172 }, @_ ) ); }
3173  
3174 4 ▶sub time_formats { return( shift->_fetch_all({
Subroutine time_formats: called CC=1 SCAR=0.0
Pod documented
3175 4 id => 'time_formats',
3176 table => 'time_formats',
3177 by => [qw( region territory locale )],
3178 has_array => [qw( time_allowed )],
3179 }, @_ ) ); }
3180  
3181 0 ▶sub time_relative_l10n { return( shift->_fetch_one({
Subroutine time_relative_l10n: not called CC=1 SCAR=6.9
Pod documented
3182 0 id => 'get_time_relative_l10n',
3183 field => 'relative',
3184 table => 'time_relative_l10n',
3185 requires => [qw( locale field_type field_length count )],
3186 default => { count => 'one' },
3187 }, @_ ) ); }
3188  
3189 0 ▶sub time_relatives_l10n { return( shift->_fetch_all({
Subroutine time_relatives_l10n: not called CC=1 SCAR=6.9
Pod documented
3190 0 id => 'time_relative_l10n',
3191 table => 'time_relative_l10n',
3192 by => [qw( locale field_type field_length count )],
3193 }, @_ ) ); }
3194  
3195 1 ▶sub timezone { return( shift->_fetch_one({
Subroutine timezone: called CC=1 SCAR=0.0
Pod documented
3196 1 id => 'get_timezone',
3197 field => 'timezone',
3198 table => 'timezones',
3199 has_array => [qw( alias )],
3200 }, @_ ) ); }
3201  
3202 6 ▶sub timezones { return( shift->_fetch_all({
Subroutine timezones: called CC=1 SCAR=0.0
Pod documented
3203 6 id => 'timezones',
3204 table => 'timezones',
3205 by => [qw( territory region tzid tz_bcpid metazone is_golden is_primary is_canonical )],
3206 has_array => [qw( alias )],
3207 }, @_ ) ); }
3208  
3209 sub timezone_canonical
3210 4 ▶{
Subroutine timezone_canonical: called CC=20 SCAR=36.2
Pod documented
3211 4 my $self = shift( @_ );
3212 4 ▶ my $tz = shift( @_ ) ||
Condition50%1/2
shift @_ || (return $self->error('No timezone was provided to get its canonical version.'))
l!l
40
MC/DC0%0/1
shift @_ || (return $self->error('No timezone was provided to get its canonical version.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
3213 return( $self->error( "No timezone was provided to get its canonical version." ) );
3214 4 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition50%1/2
$self->_dbh || (return $self->pass_error)
l!l
40
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table50%1/2
A
A= $self->_dbh
Aresult
11
00
3215 4 my $sth_id = 'sth_get_timezone';
3216 4 local $@;
3217 4 my $sth;
3218 4 ▶ unless( $sth = $self->_get_cached_statement( $sth_id ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement($sth_id)) 1 3 4
3219 {
3220 # try-catch
3221 $sth = eval
3222 1 ▶ {
Condition50%1/2
eval { do { $dbh->prepare('SELECT * FROM timezones WHERE timezone = ?') } } || (return $self->error("Unable to prepare SQL query with statement ID $sth_id to retrieve the given timezone information: ", $@ || $dbh->errstr))
l!l
10
MC/DC0%0/1
eval { do { $dbh->prepare('SELECT * FROM timezones WHERE timezone = ?') } } || (return $self->error("Unable to prepare SQL query with statement ID $sth_id to retrieve the given timezone information: ", $@ || $dbh->errstr))
eval { do { $dbh->prepare('SELECT * FROM timezones WHERE timezone = ?') } }
Truth table50%1/2
A
A= eval { do { $dbh->prepare('SELECT * FROM timezones WHERE timezone = ?') } }
Aresult
11
00
3223 1 ▶ $dbh->prepare( "SELECT * FROM timezones WHERE timezone = ?" )
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
3224 } || return( $self->error( "Unable to prepare SQL query with statement ID ${sth_id} to retrieve the given timezone information: ", ( $@ || $dbh->errstr ) ) );
3225 1 $self->_set_cached_statement( $sth_id => $sth );
3226 }
3227  
3228 # try-catch
3229 eval
3230 {
3231 4 ▶ $sth->execute( $tz );
Condition0%0/3
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
3232 4 ▶ } || return( $self->error( "Error executing SQL query '$sth->{Statement}' with statement ID ${sth_id} to retrieve the given timezone information:", ( $@ || $sth->errstr ), " with SQL query: ", $sth->{Statement} ) );
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute($tz) } } or return $self->error(qq[Error executing SQL query '$sth->{"Statement"}' with statement ID $sth_id to retrieve the given timezone information:], $@ || $sth->errstr, " with SQL query: ", $sth->{"Statement"}) 4 0 4
3233 4 my $ref = $sth->fetchrow_hashref;
3234 4 ▶ return( $self->error( "No timezone '${tz}' exists in the Locale::Unicode::Data database." ) ) if( !$ref );
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 4 4
3235 4 $self->_decode_utf8( $ref ) if( MISSING_AUTO_UTF8_DECODING );
3236 4 $self->_decode_sql_arrays( ['alias'], $ref );
3237 4 ▶ if( $ref->{is_canonical} )
Branch: 2 branches
BranchTrueFalseTotal
if ($ref->{'is_canonical'}) { } 1 3 4
elsif ($ref->{'alias'} and ref $ref->{'alias'} eq 'ARRAY' and scalar @{$ref->{'alias'};}) { } 3 0 3
3238 {
3239 1 return( $ref->{timezone} );
3240 }
3241 ▶ elsif( $ref->{alias} &&
Condition40%2/5
$ref->{"alias"} and ref $ref->{"alias"} eq "ARRAY" and scalar @{$ref->{"alias"};}
!ll
03
$ref->{"alias"} and ref $ref->{"alias"} eq "ARRAY"
!ll&&!rl&&r
003
MC/DC0%0/2
$ref->{"alias"} and ref $ref->{"alias"} eq "ARRAY" and scalar @{$ref->{"alias"};}
$ref->{"alias"} ref $ref->{"alias"} eq "ARRAY"
Truth table33%1/3
A and B
A= $ref->{"alias"}B= ref $ref->{"alias"} eq "ARRAY"
ABresult
0X0
100
111
3242 ref( $ref->{alias} ) eq 'ARRAY' &&
3243 3 scalar( @{$ref->{alias}} ) )
3244 {
3245 3 $sth_id = 'sth_get_timezone_multi_' . scalar( @{$ref->{alias}} );
3246 3 ▶ unless( $sth = $self->_get_cached_statement( $sth_id ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement($sth_id)) 2 1 3
3247 {
3248 # try-catch
3249 $sth = eval
3250 {
3251 2 $dbh->prepare( "SELECT * FROM timezones WHERE " . join( ' OR ', map{ "timezone = ?" } @{$ref->{alias}} ) )
3252 0 ▶ } || return( $self->error( "Unable to prepare SQL query with statement ID ${sth_id} to retrieve one of " . scalar( @{$ref->{alias}} ) . " timezone(s) information: ", ( $@ || $dbh->errstr ) ) );
Condition20%1/5
eval { do { $dbh->prepare('SELECT * FROM timezones WHERE ' . join(' OR ', map({'timezone = ?';} @{$$ref{'alias'};}))) } } || (return $self->error("Unable to prepare SQL query with statement ID $sth_id to retrieve one of " . scalar(@{$ref->{'alias'};}) . ' timezone(s) information: ', $@ || $dbh->errstr))
l!l
20
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/1
eval { do { $dbh->prepare('SELECT * FROM timezones WHERE ' . join(' OR ', map({'timezone = ?';} @{$$ref{'alias'};}))) } } || (return $self->error("Unable to prepare SQL query with statement ID $sth_id to retrieve one of " . scalar(@{$ref->{'alias'};}) . ' timezone(s) information: ', $@ || $dbh->errstr))
eval { do { $dbh->prepare('SELECT * FROM timezones WHERE ' . join(' OR ', map({'timezone = ?';} @{$$ref{'alias'};}))) } }
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table50%1/2
A
A= eval { do { $dbh->prepare('SELECT * FROM timezones WHERE ' . join(' OR ', map({'timezone = ?';} @{$$ref{'alias'};}))) } }
Aresult
11
00
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
3253 2 $self->_set_cached_statement( $sth_id => $sth );
3254 }
3255 # try-catch
3256 eval
3257 {
3258 3 $sth->execute( @{$ref->{alias}} );
3259 0 ▶ } || return( $self->error( "Error executing SQL query '$sth->{Statement}' with statement ID ${sth_id} to retrieve one of " . scalar( @{$ref->{alias}} ) . " timezone(s) information:", ( $@ || $sth->errstr ), " with SQL query: ", $sth->{Statement} ) );
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute(@{$$ref{"alias"};}) } } or return $self->error(qq[Error executing SQL query '$sth->{"Statement"}' with statement ID $sth_id to retrieve one of ] . scalar(@{$ref->{"alias"};}) . ' timezone(s) information:', $@ || $sth->errstr, " with SQL query: ", $sth->{"Statement"}) 3 0 3
Condition0%0/3
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
3260 3 my $all = $sth->fetchall_arrayref({});
3261 3 foreach my $this ( @$all )
3262 {
3263 3 ▶ return( $this->{timezone} ) if( $this->{is_canonical} );
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"is_canonical"} 3 0 3
3264 }
3265 }
3266 0 return( '' );
3267 }
3268  
3269 sub timezone_city
3270 1 ▶{
Subroutine timezone_city: called CC=2 SCAR=7.1
Pod documented
3271 1 my $self = shift( @_ );
3272 1 my $is_extended = $self->extend_timezones_cities;
3273 1 ▶ return( $self->_fetch_one({
Branch: 1 branch
BranchTrueFalseTotal
$is_extended ? : 1 0 1
3274 id => 'get_timezone_city',
3275 field => 'timezone',
3276 table => ( $is_extended ? 'timezones_cities_extended' : 'timezones_cities' ),
3277 requires => [qw( locale alt )],
3278 default => { alt => undef },
3279 }, @_ ) );
3280 }
3281  
3282 sub timezones_cities
3283 0 ▶{
Subroutine timezones_cities: not called CC=2 SCAR=17.9
Pod documented
3284 0 my $self = shift( @_ );
3285 0 my $is_extended = $self->extend_timezones_cities;
3286 0 ▶ return( $self->_fetch_all({
Branch: 1 branch
BranchTrueFalseTotal
$is_extended ? : 0 0 0
3287 id => 'timezones_cities',
3288 table => ( $is_extended ? 'timezones_cities_extended' : 'timezones_cities' ),
3289 by => [qw( locale alt )],
3290 }, @_ ) );
3291 }
3292  
3293 7 ▶sub timezone_formats { return( shift->_fetch_one({
Subroutine timezone_formats: called CC=1 SCAR=0.0
Pod documented
3294 7 id => 'get_timezone_formats',
3295 field => 'type',
3296 table => 'timezones_formats',
3297 requires => [qw( locale subtype )],
3298 default => { subtype => undef },
3299 }, @_ ) ); }
3300  
3301 0 ▶sub timezones_formats { return( shift->_fetch_all({
Subroutine timezones_formats: not called CC=1 SCAR=6.9
Pod documented
3302 0 id => 'timezones_formats',
3303 table => 'timezones_formats',
3304 by => [qw( locale type subtype format_pattern )],
3305 }, @_ ) ); }
3306  
3307 2 ▶sub timezone_info { return( shift->_fetch_one({
Subroutine timezone_info: called CC=1 SCAR=0.0
Pod documented
3308 2 id => 'get_timezone_info',
3309 field => 'timezone',
3310 table => 'timezones_info',
3311 requires => [qw( start )],
3312 default => { start => undef },
3313 }, @_ ) ); }
3314  
3315 4 ▶sub timezones_info { return( shift->_fetch_all({
Subroutine timezones_info: called CC=1 SCAR=0.0
Pod documented
3316 4 id => 'timezones_info',
3317 table => 'timezones_info',
3318 by => [qw( timezone metazone start until )],
3319 }, @_ ) ); }
3320  
3321 2 ▶sub timezone_names { return( shift->_fetch_one({
Subroutine timezone_names: called CC=1 SCAR=0.0
Pod documented
3322 2 id => 'get_timezone_names',
3323 field => 'timezone',
3324 table => 'timezones_names',
3325 requires => [qw( locale width )],
3326 default => { start => undef },
3327 }, @_ ) ); }
3328  
3329 0 ▶sub timezones_names { return( shift->_fetch_all({
Subroutine timezones_names: not called CC=1 SCAR=6.9
Pod documented
3330 0 id => 'timezones_names',
3331 table => 'timezones_names',
3332 by => [qw( locale timezone width )],
3333 }, @_ ) ); }
3334  
3335 2 ▶sub unit_alias { return( shift->_fetch_one({
Subroutine unit_alias: called CC=1 SCAR=0.0
Pod documented
3336 2 id => 'get_unit_alias',
3337 field => 'alias',
3338 table => 'unit_aliases',
3339 }, @_ ) ); }
3340  
3341 0 ▶sub unit_aliases { return( shift->_fetch_all({
Subroutine unit_aliases: not called CC=1 SCAR=6.9
Pod documented
3342 0 id => 'unit_aliases',
3343 table => 'unit_aliases',
3344 }, @_ ) ); }
3345  
3346 0 ▶sub unit_constant { return( shift->_fetch_one({
Subroutine unit_constant: not called CC=1 SCAR=6.9
Pod documented
3347 0 id => 'get_unit_constant',
3348 field => 'constant',
3349 table => 'unit_constants',
3350 }, @_ ) ); }
3351  
3352 0 ▶sub unit_constants { return( shift->_fetch_all({
Subroutine unit_constants: not called CC=1 SCAR=6.9
Pod documented
3353 0 id => 'unit_constants',
3354 table => 'unit_constants',
3355 }, @_ ) ); }
3356  
3357 1 ▶sub unit_conversion { return( shift->_fetch_one({
Subroutine unit_conversion: called CC=1 SCAR=0.0
Pod documented
3358 1 id => 'get_unit_conversion',
3359 field => 'source',
3360 table => 'unit_conversions',
3361 has_array => [qw( systems )],
3362 }, @_ ) ); }
3363  
3364 2 ▶sub unit_conversions { return( shift->_fetch_all({
Subroutine unit_conversions: called CC=1 SCAR=0.0
Pod documented
3365 2 id => 'unit_conversions',
3366 table => 'unit_conversions',
3367 by => [qw( base_unit category )],
3368 has_array => [qw( systems )],
3369 }, @_ ) ); }
3370  
3371 1 ▶sub unit_l10n { return( shift->_fetch_one({
Subroutine unit_l10n: called CC=1 SCAR=0.0
Pod documented
3372 1 id => 'get_unit_l10n',
3373 field => 'unit_id',
3374 table => 'units_l10n',
3375 requires => [qw( locale format_length unit_type count gender gram_case )],
3376 default => { count => undef, gender => undef, gram_case => undef },
3377 }, @_ ) ); }
3378  
3379 2 ▶sub units_l10n { return( shift->_fetch_all({
Subroutine units_l10n: called CC=1 SCAR=0.0
Pod documented
3380 2 id => 'units_l10n',
3381 table => 'units_l10n',
3382 by => [qw( locale format_length unit_type unit_id pattern_type count gender gram_case )],
3383 }, @_ ) ); }
3384  
3385 1 ▶sub unit_prefix { return( shift->_fetch_one({
Subroutine unit_prefix: called CC=1 SCAR=0.0
Pod documented
3386 1 id => 'get_unit_prefix',
3387 field => 'unit_id',
3388 table => 'unit_prefixes',
3389 }, @_ ) ); }
3390  
3391 0 ▶sub unit_prefixes { return( shift->_fetch_all({
Subroutine unit_prefixes: not called CC=1 SCAR=6.9
Pod documented
3392 0 id => 'unit_prefixes',
3393 table => 'unit_prefixes',
3394 }, @_ ) ); }
3395  
3396 1 ▶sub unit_pref { return( shift->_fetch_one({
Subroutine unit_pref: called CC=1 SCAR=0.0
Pod documented
3397 1 id => 'get_unit_pref',
3398 field => 'unit_id',
3399 table => 'unit_prefs',
3400 }, @_ ) ); }
3401  
3402 2 ▶sub unit_prefs { return( shift->_fetch_all({
Subroutine unit_prefs: called CC=1 SCAR=0.0
Pod documented
3403 2 id => 'unit_prefs',
3404 table => 'unit_prefs',
3405 by => [qw( territory category )],
3406 }, @_ ) ); }
3407  
3408 1 ▶sub unit_quantity { return( shift->_fetch_one({
Subroutine unit_quantity: called CC=1 SCAR=0.0
Pod documented
3409 1 id => 'get_unit_quantity',
3410 field => 'base_unit',
3411 table => 'unit_quantities',
3412 }, @_ ) ); }
3413  
3414 1 ▶sub unit_quantities { return( shift->_fetch_all({
Subroutine unit_quantities: called CC=1 SCAR=0.0
Pod documented
3415 1 id => 'unit_quantities',
3416 table => 'unit_quantities',
3417 by => [qw( quantity )],
3418 has_status => 1,
3419 }, @_ ) ); }
3420  
3421 1 ▶sub variant { return( shift->_fetch_one({
Subroutine variant: called CC=1 SCAR=0.0
Pod documented
3422 1 id => 'get_variant',
3423 field => 'variant',
3424 table => 'variants',
3425 }, @_ ) ); }
3426  
3427 0 ▶sub variants { return( shift->_fetch_all({
Subroutine variants: not called CC=1 SCAR=6.9
Pod documented
3428 0 id => 'variants',
3429 table => 'variants',
3430 has_status => 1,
3431 }, @_ ) ); }
3432  
3433 1 ▶sub variant_l10n { return( shift->_fetch_one({
Subroutine variant_l10n: called CC=1 SCAR=0.0
Pod documented
3434 1 id => 'get_variant_l10n',
3435 field => 'variant',
3436 table => 'variants_l10n',
3437 requires => [qw( locale alt )],
3438 default => { alt => undef },
3439 }, @_ ) ); }
3440  
3441 1 ▶sub variants_l10n { return( shift->_fetch_all({
Subroutine variants_l10n: called CC=1 SCAR=0.0
Pod documented
3442 1 id => 'variants_l10n',
3443 table => 'variants_l10n',
3444 by => [qw( locale alt )],
3445 }, @_ ) ); }
3446  
3447 1 ▶sub week_preference { return( shift->_fetch_one({
Subroutine week_preference: called CC=1 SCAR=0.0
Pod documented
3448 1 id => 'get_week_preference',
3449 field => 'locale',
3450 table => 'week_preferences',
3451 has_array => [qw( ordering )],
3452 }, @_ ) ); }
3453  
3454 0 ▶sub week_preferences { return( shift->_fetch_all({
Subroutine week_preferences: not called CC=1 SCAR=6.9
Pod documented
3455 0 id => 'week_preferences',
3456 table => 'week_preferences',
3457 has_array => [qw( ordering )],
3458 }, @_ ) ); }
3459  
3460 # Returns the data_aliases rule that applies to the given keys: its locale must be in the
3461 # inheritance tree, and all its source columns must be among the keys with the same values.
3462 # When several rules apply, the most specific one is used.
3463 sub _data_alias_match
3464 7 ▶{
Subroutine _data_alias_match: called CC=13 SCAR=30.1
3465 7 my( $self, $rules, $keys, $tree ) = @_;
3466 7 my $in_tree = { map{ $_ => 1 } @$tree };
3467 7 my $best;
3468 7 RULE: foreach my $rule ( @$rules )
3469 {
3470 330 ▶ next if( !$in_tree->{ $rule->{locale} } );
Branch: 1 branch
BranchTrueFalseTotal
unless $$in_tree{$rule->{"locale"}} 0 330 330
3471 330 my $src = $rule->{source};
3472 330 foreach my $col ( keys( %$src ) )
3473 {
3474 401 ▶ next RULE if( !CORE::exists( $keys->{ $col } ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $keys->{$col} 0 401 401
3475 401 my( $v, $w ) = ( $keys->{ $col }, $src->{ $col } );
3476 # A search value (array of values, operator or regular expression) cannot
3477 # be matched against a rule.
3478 401 ▶ next RULE if( ref( $v ) && !( Scalar::Util::blessed( $v ) && overload::Method( $v => '""' ) ) );
Branch: 1 branch
BranchTrueFalseTotal
if ref $v and not builtin::blessed($v) && overload::Method($v, "\"\"") 0 401 401
Condition16%1/6
ref $v and not builtin::blessed($v) && overload::Method($v, "\"\"")
!ll&&!rl&&r
40100
builtin::blessed($v) && overload::Method($v, '""')
!ll&&!rl&&r
000
MC/DC0%0/3
ref $v and not builtin::blessed($v) && overload::Method($v, "\"\"")
ref $v builtin::blessed($v) overload::Method($v, '""')
Truth table25%1/4
A and not(B && C)
A= ref $vB= builtin::blessed($v)C= overload::Method($v, '""')
ABCresult
0XX0
1110
10X1
1101
3479 401 ▶ next RULE if( defined( $v ) != defined( $w ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $v != defined $w 0 401 401
3480 401 ▶ next RULE if( defined( $v ) && lc( "$v" ) ne lc( $w ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $v and lc "$v" ne lc $w 325 76 401
Condition66%2/3
defined $v and lc "$v" ne lc $w
!ll&&!rl&&r
076325
MC/DC50%1/2
defined $v and lc "$v" ne lc $w
defined $v lc "$v" ne lc $w
Truth table66%2/3
A and B
A= defined $vB= lc "$v" ne lc $w
ABresult
0X0
100
111
3481 }
3482 0 ▶ $best = $rule if( !defined( $best ) || scalar( keys( %$src ) ) > scalar( keys( %{$best->{source}} ) ) );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $best or scalar keys %$src > scalar keys %{$$best{"source"};} 5 0 5
Condition33%1/3
not defined $best or scalar keys %$src > scalar keys %{$$best{"source"};}
l!l&&r!l&&!r
500
MC/DC0%0/2
not defined $best or scalar keys %$src > scalar keys %{$$best{"source"};}
not defined $best scalar keys %$src > scalar keys %{$$best{"source"};}
Truth table33%1/3
not(A) or B
A= not defined $bestB= scalar keys %$src > scalar keys %{$$best{"source"};}
ABresult
1X1
011
000
3483 }
3484 7 return( $best );
3485 }
3486  
3487 # Loads, once per object, the data_aliases rules for a given table.
3488 sub _data_alias_rules
3489 7 ▶{
Subroutine _data_alias_rules: called CC=6 SCAR=18.0
3490 7 my( $self, $table ) = @_;
3491 7 ▶ $self->{_data_alias_rules} //= {};
Condition100%2/2
$self->{"_data_alias_rules"} //= {}
l!l
61
MC/DC100%1/1
$self->{"_data_alias_rules"} //= {}
$self->{"_data_alias_rules"}
Truth table100%2/2
A
A= $self->{"_data_alias_rules"}
Aresult
11
00
3492 7 ▶ return( $self->{_data_alias_rules}->{ $table } ) if( CORE::exists( $self->{_data_alias_rules}->{ $table } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_data_alias_rules"}{$table} 4 3 7
3493 3 ▶ my $all = $self->data_aliases( table_name => $table ) || return( $self->pass_error );
Condition50%1/2
$self->data_aliases('table_name', $table) || (return $self->pass_error)
l!l
30
MC/DC0%0/1
$self->data_aliases('table_name', $table) || (return $self->pass_error)
$self->data_aliases('table_name', $table)
Truth table50%1/2
A
A= $self->data_aliases('table_name', $table)
Aresult
11
00
3494 3 my $j = JSON->new;
3495 3 my $rules = [];
3496 3 foreach my $ref ( @$all )
3497 {
3498 128 my( $src, $tgt ) = eval{ ( $j->decode( $ref->{source} ), $j->decode( $ref->{target} ) ) };
3499 128 ▶ return( $self->error( "Invalid JSON data for the data alias ID $ref->{data_alias_id}: $@" ) ) if( $@ );
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 128 128
3500 128 push( @$rules, { %$ref, source => $src, target => $tgt } );
3501 }
3502 3 return( $self->{_data_alias_rules}->{ $table } = $rules );
3503 }
3504  
3505 sub _dbh
3506 216 ▶{
Subroutine _dbh: called CC=25 SCAR=41.2
3507 216 my $self = shift( @_ );
3508 216 my $opts = $self->_get_args_as_hash( @_ );
3509 216 ▶ my $file = $opts->{datafile} || $self->datafile || $DB_FILE;
Condition33%2/6
$opts->{'datafile'} || $self->datafile || $Locale::Unicode::Data::DB_FILE
l!l&&r!l&&!r
21600
$opts->{"datafile"} or $self->datafile
l!l&&r!l&&!r
02160
MC/DC0%0/3
$opts->{'datafile'} || $self->datafile || $Locale::Unicode::Data::DB_FILE
$opts->{"datafile"} $self->datafile $Locale::Unicode::Data::DB_FILE
Truth table25%1/4
A or B || C
A= $opts->{"datafile"}B= $self->datafileC= $Locale::Unicode::Data::DB_FILE
ABCresult
1XX1
01X1
0011
0000
3510 216 my $dbh;
3511 216 ▶ my $tid = ( $Config{useithreads} && $INC{'threads.pm'} && threads->can('tid') ) ? threads->tid() : $$;
Branch: 1 branch
BranchTrueFalseTotal
$Locale::Unicode::Data::Config{'useithreads'} && $INC{'threads.pm'} && 'threads'->can('tid') ? : 0 216 216
Condition33%2/6
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"} and "threads"->can("tid")
!ll&&!rl&&r
21600
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"}
!ll&&!rl&&r
21600
MC/DC0%0/3
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"} and "threads"->can("tid")
$Locale::Unicode::Data::Config{"useithreads"} $INC{"threads.pm"} "threads"->can("tid")
Truth table25%1/4
A and B and C
A= $Locale::Unicode::Data::Config{"useithreads"}B= $INC{"threads.pm"}C= "threads"->can("tid")
ABCresult
0XX0
10X0
1100
1111
3512 216 ▶ if( $DBH &&
Branch: 1 branch
BranchTrueFalseTotal
if ($Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid} and ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid}{$file} and $Locale::Unicode::Data::DBH->{$tid}{$file} and builtin::blessed($Locale::Unicode::Data::DBH->{$tid}{$file}) and $Locale::Unicode::Data::DBH->{$tid}{$file}->isa("DBI::db") and $Locale::Unicode::Data::DBH->{$tid}{$file}->ping) 210 6 216
Condition62%17/27
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid} and ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid}{$file} and $Locale::Unicode::Data::DBH->{$tid}{$file} and builtin::blessed($Locale::Unicode::Data::DBH->{$tid}{$file}) and $Locale::Unicode::Data::DBH->{$tid}{$file}->isa("DBI::db") and $Locale::Unicode::Data::DBH->{$tid}{$file}->ping
!ll&&!rl&&r
60210
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid} and ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid}{$file} and $Locale::Unicode::Data::DBH->{$tid}{$file} and builtin::blessed($Locale::Unicode::Data::DBH->{$tid}{$file}) and $Locale::Unicode::Data::DBH->{$tid}{$file}->isa("DBI::db")
!ll&&!rl&&r
60210
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid} and ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid}{$file} and $Locale::Unicode::Data::DBH->{$tid}{$file} and builtin::blessed($Locale::Unicode::Data::DBH->{$tid}{$file})
!ll&&!rl&&r
60210
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid} and ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid}{$file} and $Locale::Unicode::Data::DBH->{$tid}{$file}
!ll&&!rl&&r
60210
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid} and ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid}{$file}
!ll&&!rl&&r
60210
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid} and ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH"
!ll&&!rl&&r
60210
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid}
!ll&&!rl&&r
60210
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid}
!ll&&!rl&&r
06210
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH"
!ll&&!rl&&r
00216
MC/DC10%1/10
$Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid} and defined $Locale::Unicode::Data::DBH->{$tid} and ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" and exists $Locale::Unicode::Data::DBH->{$tid}{$file} and $Locale::Unicode::Data::DBH->{$tid}{$file} and builtin::blessed($Locale::Unicode::Data::DBH->{$tid}{$file}) and $Locale::Unicode::Data::DBH->{$tid}{$file}->isa("DBI::db") and $Locale::Unicode::Data::DBH->{$tid}{$file}->ping
$Locale::Unicode::Data::DBH ref $Locale::Unicode::Data::DBH eq "HASH" exists $Locale::Unicode::Data::DBH->{$tid} defined $Locale::Unicode::Data::DBH->{$tid} ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" exists $Locale::Unicode::Data::DBH->{$tid}{$file} $Locale::Unicode::Data::DBH->{$tid}{$file} builtin::blessed($Locale::Unicode::Data::DBH->{$tid}{$file}) $Locale::Unicode::Data::DBH->{$tid}{$file}->isa("DBI::db") $Locale::Unicode::Data::DBH->{$tid}{$file}->ping
Truth table18%2/11
A and B and C and D and E and F and G and H and I and J
A= $Locale::Unicode::Data::DBHB= ref $Locale::Unicode::Data::DBH eq "HASH"C= exists $Locale::Unicode::Data::DBH->{$tid}D= defined $Locale::Unicode::Data::DBH->{$tid}E= ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH"F= exists $Locale::Unicode::Data::DBH->{$tid}{$file}G= $Locale::Unicode::Data::DBH->{$tid}{$file}H= builtin::blessed($Locale::Unicode::Data::DBH->{$tid}{$file})I= $Locale::Unicode::Data::DBH->{$tid}{$file}->isa("DBI::db")J= $Locale::Unicode::Data::DBH->{$tid}{$file}->ping
ABCDEFGHIJresult
0XXXXXXXXX0
10XXXXXXXX0
110XXXXXXX0
1110XXXXXX0
11110XXXXX0
111110XXXX0
1111110XXX0
11111110XX0
111111110X0
11111111100
11111111111
3513 ref( $DBH ) eq 'HASH' &&
3514 exists( $DBH->{ $tid } ) &&
3515 defined( $DBH->{ $tid } ) &&
3516 ref( $DBH->{ $tid } ) eq 'HASH' &&
3517 exists( $DBH->{ $tid }->{ $file } ) &&
3518 $DBH->{ $tid }->{ $file } &&
3519 Scalar::Util::blessed( $DBH->{ $tid }->{ $file } ) &&
3520 $DBH->{ $tid }->{ $file }->isa( 'DBI::db' ) &&
3521 $DBH->{ $tid }->{ $file }->ping )
3522 {
3523 210 return( $DBH->{ $tid }->{ $file } );
3524 }
3525  
3526  
3527 6 ▶ if( !-e( $file ) )
Branch: 5 branches
BranchTrueFalseTotal
if (not -e $file) { } 0 6 6
elsif (not -f $file) { } 0 6 6
elsif (-z $file) { } 0 6 6
elsif (not -r $file) { } 0 6 6
elsif ('version'->parse($DBD::SQLite::sqlite_version) < 'version'->parse('3.6.19')) { } 0 6 6
3528 {
3529 0 return( $self->error( "Unicode CLDR SQLite database file ${file} does not exist!" ) );
3530 }
3531 elsif( !-f( $file ) )
3532 {
3533 0 return( $self->error( "Unicode CLDR SQLite database file ${file} is not a regular file." ) );
3534 }
3535 elsif( -z( $file ) )
3536 {
3537 0 return( $self->error( "Unicode CLDR SQLite database file ${file} is empty!" ) );
3538 }
3539 elsif( !-r( $file ) )
3540 {
3541 0 return( $self->error( "Unicode CLDR SQLite database file ${file} is not readable by uid $>" ) );
3542 }
3543 elsif( version->parse( $DBD::SQLite::sqlite_version ) < version->parse( '3.6.19' ) )
3544 {
3545 0 return( $self->error( "SQLite driver version 3.6.19 or higher is required. You have version ", $DBD::SQLite::sqlite_version ) );
3546 }
3547  
3548 6 if( HAS_CONSTANTS )
3549 {
3550 6 require DBD::SQLite::Constants;
3551 }
3552  
3553 6 my $params =
3554 {
3555 ( HAS_CONSTANTS ? ( sqlite_open_flags => DBD::SQLite::Constants::SQLITE_OPEN_READONLY ) : () ),
3556 };
3557 6 ▶ $dbh = DBI->connect( "dbi:SQLite:dbname=${file}", '', '', $params ) ||
Condition50%1/2
'DBI'->connect("dbi:SQLite:dbname=$file", '', '', $params) || (return $self->error("Unable to make connection to Unicode CLDR SQLite database file ${file}: ", $DBI::errstr))
l!l
60
MC/DC0%0/1
'DBI'->connect("dbi:SQLite:dbname=$file", '', '', $params) || (return $self->error("Unable to make connection to Unicode CLDR SQLite database file ${file}: ", $DBI::errstr))
'DBI'->connect("dbi:SQLite:dbname=$file", '', '', $params)
Truth table50%1/2
A
A= 'DBI'->connect("dbi:SQLite:dbname=$file", '', '', $params)
Aresult
11
00
3558 return( $self->error( "Unable to make connection to Unicode CLDR SQLite database file ${file}: ", $DBI::errstr ) );
3559 # Raise the SQLite page cache so that repeated queries against the 112 MB bundled
3560 # database do not require repeated disk reads on every call. The default cache
3561 # (2000 pages, about 8 MB) is too small for this database. A negative value is
3562 # interpreted by SQLite as kilobytes, so -65536 sets a 64 MB ceiling.
3563 # The cache is allocated lazily: only pages actually read are cached, so the
3564 # true resident-memory impact under normal use (a few locale lookups per
3565 # request) remains well below this ceiling.
3566 6 my $rv = $dbh->do( "PRAGMA cache_size = -65536" );
3567 6 ▶ if( !defined( $rv ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rv) 0 6 6
3568 {
3569 # Unable to set SQLite cache_size pragma
3570 }
3571 # See: <https://metacpan.org/release/ADAMK/DBD-SQLite-1.27/view/lib/DBD/SQLite.pm#Foreign-Keys>
3572 6 ▶ if( !defined( $dbh->do( "PRAGMA foreign_keys = ON" ) ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dbh->do("PRAGMA foreign_keys = ON")) 0 6 6
3573 {
3574 # Unable to enable SQLite foreign_keys pragma
3575 }
3576 # UTF-8 decoding is done natively from version 1.68 onward
3577 6 if( !MISSING_AUTO_UTF8_DECODING )
3578 {
3579 6 $dbh->{sqlite_string_mode} = DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_FALLBACK;
3580 }
3581 6 ▶ $DBH->{ $tid } //= {};
Condition50%1/2
$Locale::Unicode::Data::DBH->{$tid} //= {}
l!l
06
MC/DC0%0/1
$Locale::Unicode::Data::DBH->{$tid} //= {}
$Locale::Unicode::Data::DBH->{$tid}
Truth table50%1/2
A
A= $Locale::Unicode::Data::DBH->{$tid}
Aresult
11
00
3582 6 return( $DBH->{ $tid }->{ $file } = $dbh );
3583 }
3584  
3585 sub _decode_sql_arrays
3586 5080 ▶{
Subroutine _decode_sql_arrays: called CC=16 SCAR=31.8
3587 5080 my $self = shift( @_ );
3588 5080 ▶ die( "\$cldr->_decode_sql_arrays( \$array_ref_of_array_fields, \$data )" ) if( @_ != 2 );
Branch: 1 branch
BranchTrueFalseTotal
if @_ != 2 0 5080 5080
3589 5080 my( $where, $ref ) = @_;
3590 5080 ▶ if( ref( $where ) ne 'ARRAY' )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $where ne 'ARRAY') { } 0 5080 5080
elsif (ref($ref // '') ne 'HASH' and builtin::reftype($ref // '') ne 'ARRAY') { } 0 9955 9955
3591 {
3592 0 die( "\$cldr->_decode_sql_arrays( \$array_ref_of_array_fields, \$data )" );
3593 }
3594 ▶ elsif( ref( $ref // '' ) ne 'HASH' && Scalar::Util::reftype( $ref // '' ) ne 'ARRAY' )
Condition57%4/7
ref($ref // "") ne "HASH" and builtin::reftype($ref // "") ne "ARRAY"
!ll&&!rl&&r
48752050
$ref // ""
l!l
50800
$ref // ""
l!l
2050
MC/DC0%0/2
ref($ref // "") ne "HASH" and builtin::reftype($ref // "") ne "ARRAY"
$ref $ref
Truth table33%1/3
A and B
A= $refB= $ref
ABresult
0X0
100
111
3595 {
3596 0 die( "\$cldr->_decode_sql_arrays( \$array_ref_of_array_fields, \$data )" );
3597 }
3598  
3599 5080 my $j = JSON->new->relaxed;
3600 5080 local $@;
3601 5080 ▶ if( ref( $ref ) eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $ref eq 'HASH') { } 4875 205 5080
elsif (builtin::reftype($ref) eq 'ARRAY') { } 205 0 205
3602 {
3603 4875 foreach my $field ( @$where )
3604 {
3605 4954 ▶ if( exists( $ref->{ $field } ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ref->{$field} and defined $ref->{$field} and length $ref->{$field}) 4510 444 4954
Condition66%4/6
exists $ref->{$field} and defined $ref->{$field} and length $ref->{$field}
!ll&&!rl&&r
44404510
exists $ref->{$field} and defined $ref->{$field}
!ll&&!rl&&r
04444510
MC/DC33%1/3
exists $ref->{$field} and defined $ref->{$field} and length $ref->{$field}
exists $ref->{$field} defined $ref->{$field} length $ref->{$field}
Truth table50%2/4
A and B and C
A= exists $ref->{$field}B= defined $ref->{$field}C= length $ref->{$field}
ABCresult
0XX0
10X0
1100
1111
3606 defined( $ref->{ $field } ) &&
3607 length( $ref->{ $field } ) )
3608 {
3609 my $decoded = eval
3610 4510 {
3611 4510 $j->decode( $ref->{ $field } );
3612 };
3613 4510 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 4510 4510
3614 {
3615 0 warn( "Warning only: error attempting to decode JSON array in field \"${field}\" for value '", $ref->{ $field }, "': $@" );
3616 0 $ref->{ $field } = [];
3617 }
3618 else
3619 {
3620 4510 $ref->{ $field } = $decoded;
3621 }
3622 }
3623 }
3624 }
3625 elsif( Scalar::Util::reftype( $ref ) eq 'ARRAY' )
3626 {
3627 205 ▶ for( my $i = 0; $i < scalar( @$ref ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$ref) 4361 205 4566
3628 {
3629 4361 ▶ if( ref( $ref->[$i] ) ne 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref->[$i] ne "HASH") 0 4361 4361
3630 {
3631 0 warn( "SQL data at offset ${i} is not an HASH reference." );
3632 0 next;
3633 }
3634 4361 $self->_decode_sql_arrays( $where, $ref->[$i] );
3635 }
3636 }
3637 5080 return( $ref );
3638 }
3639  
3640 sub _decode_utf8
3641 0 ▶{
Subroutine _decode_utf8: not called CC=14 SCAR=53.5
3642 0 my $self = shift( @_ );
3643 0 my $this = shift( @_ );
3644 0 ▶ if( ref( $this ) eq 'HASH' )
Branch: 3 branches
BranchTrueFalseTotal
if (ref $this eq 'HASH') { } 0 0 0
elsif (ref $this eq 'ARRAY') { } 0 0 0
elsif (not ref $this) { } 0 0 0
3645 {
3646 0 foreach my $k ( keys( %$this ) )
3647 {
3648 0 ▶ next if( !defined( $this->{ $k } ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $this->{$k} 0 0 0
3649 0 ▶ if( ref( $this->{ $k } ) eq 'ARRAY' ||
Branch: 1 branch
BranchTrueFalseTotal
if (ref $this->{$k} eq "ARRAY" or not ref $this->{$k}) 0 0 0
Condition0%0/3
ref $this->{$k} eq "ARRAY" or not ref $this->{$k}
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $this->{$k} eq "ARRAY" or not ref $this->{$k}
ref $this->{$k} eq "ARRAY" not ref $this->{$k}
Truth table0%0/3
A or not(B)
A= ref $this->{$k} eq "ARRAY"B= not ref $this->{$k}
ABresult
1X1
011
000
3650 !ref( $this->{ $k } ) )
3651 {
3652 0 $this->{ $k } = $self->_decode_utf8( $this->{ $k } );
3653 }
3654 }
3655 }
3656 elsif( ref( $this ) eq 'ARRAY' )
3657 {
3658 0 ▶ for( my $i = 0; $i < scalar( @$this ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$this) 0 0 0
3659 {
3660 0 ▶ next if( !defined( $this->[$i] ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $this->[$i] 0 0 0
3661 0 ▶ if( ref( $this->[$i] ) eq 'HASH' ||
Branch: 1 branch
BranchTrueFalseTotal
if (ref $this->[$i] eq "HASH" or not ref $this->[$i]) 0 0 0
Condition0%0/3
ref $this->[$i] eq "HASH" or not ref $this->[$i]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $this->[$i] eq "HASH" or not ref $this->[$i]
ref $this->[$i] eq "HASH" not ref $this->[$i]
Truth table0%0/3
A or not(B)
A= ref $this->[$i] eq "HASH"B= not ref $this->[$i]
ABresult
1X1
011
000
3662 !ref( $this->[$i] ) )
3663 {
3664 0 $this->[$i] = $self->_decode_utf8( $this->[$i] );
3665 }
3666 }
3667 }
3668 elsif( !ref( $this ) )
3669 {
3670 my $val = eval
3671 0 {
3672 0 Encode::decode_utf8( $this, Encode::FB_CROAK );
3673 };
3674 0 ▶ if( $@ )
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
3675 {
3676 0 ▶ warn( "Error utf-8 decoding: $@" ) if( warnings::enabled() );
Branch: 1 branch
BranchTrueFalseTotal
if warnings::enabled() 0 0 0
3677 0 return( $this );
3678 }
3679 else
3680 {
3681 0 return( $val );
3682 }
3683 }
3684 0 return( $this );
3685 }
3686  
3687 sub _fetch_all
3688 328 ▶{
Subroutine _fetch_all: called CC=101 SCAR=75.2
3689 328 my $self = shift( @_ );
3690 328 ▶ my $def = shift( @_ ) || return( $self->error( "No hash definition provided." ) );
Condition50%1/2
shift @_ || (return $self->error('No hash definition provided.'))
l!l
3280
MC/DC0%0/1
shift @_ || (return $self->error('No hash definition provided.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
3691 328 ▶ return( $self->error( "Hash definition is not an hash reference." ) ) if( ref( $def ) ne 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $def ne "HASH" 0 328 328
3692 328 ▶ my $table = $def->{table} || return( $self->error( "No SQL table name was provided." ) );
Condition50%1/2
$def->{'table'} || (return $self->error('No SQL table name was provided.'))
l!l
3280
MC/DC0%0/1
$def->{'table'} || (return $self->error('No SQL table name was provided.'))
$def->{'table'}
Truth table50%1/2
A
A= $def->{'table'}
Aresult
11
00
3693 328 ▶ my $id = $def->{id} || $table;
Condition33%1/3
$def->{'id'} || $table
l!l&&r!l&&!r
32800
MC/DC0%0/2
$def->{'id'} || $table
$def->{'id'} $table
Truth table33%1/3
A || B
A= $def->{'id'}B= $table
ABresult
1X1
011
000
3694 328 ▶ my $what = $def->{what} || $table;
Condition33%1/3
$def->{'what'} || $table
l!l&&r!l&&!r
03280
MC/DC0%0/2
$def->{'what'} || $table
$def->{'what'} $table
Truth table33%1/3
A || B
A= $def->{'what'}B= $table
ABresult
1X1
011
000
3695 328 ▶ my $order = exists( $def->{order} ) ? $def->{order} : 'rowid';
Branch: 1 branch
BranchTrueFalseTotal
exists $def->{'order'} ? : 33 295 328
3696 328 my $opts = $self->_get_args_as_hash( @_ );
3697 my $status = $def->{has_status}
3698 ? $def->{has_status} =~ /[a-zA-Z]/
3699 ? $def->{has_status}
3700 328 ▶ : 'status'
Branch: 2 branches
BranchTrueFalseTotal
$def->{'has_status'} ? : 10 318 328
$def->{'has_status'} =~ /[a-zA-Z]/ ? : 0 10 10
3701 : undef;
3702 328 ▶ my $by = ( exists( $def->{by} ) && ref( $def->{by} ) eq 'ARRAY' ? $def->{by} : [] );
Branch: 1 branch
BranchTrueFalseTotal
exists $def->{'by'} && ref $def->{'by'} eq 'ARRAY' ? : 328 0 328
Condition33%1/3
exists $def->{"by"} and ref $def->{"by"} eq "ARRAY"
!ll&&!rl&&r
00328
MC/DC0%0/2
exists $def->{"by"} and ref $def->{"by"} eq "ARRAY"
exists $def->{"by"} ref $def->{"by"} eq "ARRAY"
Truth table33%1/3
A and B
A= exists $def->{"by"}B= ref $def->{"by"} eq "ARRAY"
ABresult
0X0
100
111
3703 328 my $order_by_value = [];
3704 328 ▶ if( exists( $opts->{order_by_value} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts->{"order_by_value"} and defined $opts->{"order_by_value"}) 0 328 328
Condition33%1/3
exists $opts->{"order_by_value"} and defined $opts->{"order_by_value"}
!ll&&!rl&&r
32800
MC/DC0%0/2
exists $opts->{"order_by_value"} and defined $opts->{"order_by_value"}
exists $opts->{"order_by_value"} defined $opts->{"order_by_value"}
Truth table33%1/3
A and B
A= exists $opts->{"order_by_value"}B= defined $opts->{"order_by_value"}
ABresult
0X0
100
111
3705 defined( $opts->{order_by_value} ) )
3706 {
3707 0 ▶ if( ref( $opts->{order_by_value} ) eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts->{'order_by_value'} eq 'ARRAY') { } 0 0 0
3708 {
3709 0 $order_by_value = $opts->{order_by_value};
3710 }
3711 else
3712 {
3713 0 $order_by_value = [$opts->{order_by_value}];
3714 }
3715 }
3716  
3717 328 ▶ if( scalar( @$order_by_value ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$order_by_value) 0 328 328
3718 {
3719 0 ▶ if( scalar( @$order_by_value ) != 2 )
Branch: 3 branches
BranchTrueFalseTotal
if (scalar @$order_by_value != 2) { } 0 0 0
elsif (ref $order_by_value->[1] ne 'ARRAY') { } 0 0 0
elsif (not scalar @{$order_by_value->[1];}) { } 0 0 0
3720 {
3721 0 die( "Invalid number of parameter for order by field value. You need to provide a field name and an array reference of values." );
3722 }
3723 elsif( ref( $order_by_value->[1] ) ne 'ARRAY' )
3724 {
3725 0 die( "Invalid parameters provided for order by field value. The second parameter must be an array reference of value to sort with." );
3726 }
3727 0 elsif( !scalar( @{$order_by_value->[1]} ) )
3728 {
3729 0 ▶ die( "The array of value to sort the data for field '", ( $order_by_value->[0] // 'undef' ), "' is empty." );
Condition0%0/2
$order_by_value->[0] // "undef"
l!l
00
MC/DC0%0/1
$order_by_value->[0] // "undef"
$order_by_value->[0]
Truth table0%0/2
A
A= $order_by_value->[0]
Aresult
11
00
3730 }
3731 0 my $field = $order_by_value->[0];
3732 0 my @cases;
3733 0 ▶ for( my $i = 0; $i < scalar( @{$order_by_value->[1]} ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$order_by_value->[1];}) 0 0 0
3734 {
3735 0 push( @cases, sprintf( "WHEN '%s' THEN %d", $order_by_value->[1]->[$i], $i ) );
3736 }
3737 0 my $case = "CASE ${field} " . join( ' ', @cases ) . ' END';
3738 0 $order = $case;
3739 }
3740 # order option to override any default order directive
3741 328 ▶ if( exists( $opts->{order} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts->{"order"}) 7 321 328
3742 {
3743 7 my( $field, $datatype );
3744 7 ▶ if( ref( $opts->{order} ) eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $opts->{'order'} eq 'HASH') { } 0 7 7
elsif (ref $opts->{'order'} eq 'ARRAY') { } 7 0 7
3745 {
3746 0 my @keys = keys( %{$opts->{order}} );
3747 0 ▶ if( scalar( @keys ) != 1 )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys != 1) 0 0 0
3748 {
3749 0 local $" = ', ';
3750 0 die( "You can only specify one order field to cast. Here, you provided: @keys" );
3751 }
3752 0 ( $field, $datatype ) = ( $keys[0], $opts->{order}->{ $keys[0] } );
3753 }
3754 elsif( ref( $opts->{order} ) eq 'ARRAY' )
3755 {
3756 7 ▶ if( scalar( @{$opts->{order}} ) != 2 )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$opts->{"order"};} != 2) 0 7 7
3757 {
3758 0 die( "You need to provide a 2-elements array. The first element is the field name and the second element the data type. You provided ", scalar( @{$opts->{order}} ), " element(s)." );
3759 }
3760 7 ( $field, $datatype ) = @{$opts->{order}};
3761 }
3762 else
3763 {
3764 0 $field = $opts->{order};
3765 }
3766  
3767 7 ▶ if( defined( $field ) && defined( $datatype ) )
Branch: 2 branches
BranchTrueFalseTotal
if (defined $field and defined $datatype) { } 7 0 7
elsif (defined $field) { } 0 0 0
Condition33%1/3
defined $field and defined $datatype
!ll&&!rl&&r
007
MC/DC0%0/2
defined $field and defined $datatype
defined $field defined $datatype
Truth table33%1/3
A and B
A= defined $fieldB= defined $datatype
ABresult
0X0
100
111
3768 {
3769 7 ▶ if( !length( $field // '' ) )
Branch: 4 branches
BranchTrueFalseTotal
if (not length($field // '')) { } 0 7 7
elsif (not length($datatype // '')) { } 0 7 7
elsif (not $field =~ /^[a-zA-Z0-9\_]+$/) { } 0 7 7
elsif (not $datatype =~ /^[a-zA-Z0-9]+$/) { } 0 7 7
Condition50%1/2
$field // ""
l!l
70
MC/DC0%0/1
$field // ""
$field
Truth table50%1/2
A
A= $field
Aresult
11
00
3770 {
3771 0 die( "The order field value provided is empty!" );
3772 }
3773 ▶ elsif( !length( $datatype // '' ) )
Condition50%1/2
$datatype // ""
l!l
70
MC/DC0%0/1
$datatype // ""
$datatype
Truth table50%1/2
A
A= $datatype
Aresult
11
00
3774 {
3775 0 die( "The order datatype value provided is empty!" );
3776 }
3777 elsif( $field !~ /^[a-zA-Z0-9\_]+$/ )
3778 {
3779 0 die( "The order field name provided contains illegal value. It must be an alphanumerical string, with possible '_' character." );
3780 }
3781 elsif( $datatype !~ /^[a-zA-Z0-9]+$/ )
3782 {
3783 0 die( "The order field data type contains an illegal value. It must be a string of alpha numeric characters." );
3784 }
3785 7 $order = "CAST(${field} AS \U${datatype}\E)";
3786 }
3787 elsif( defined( $field ) )
3788 {
3789 0 ▶ die( "The order field value provided is empty!" ) if( !length( $field // '' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length($field // "") 0 0 0
Condition0%0/2
$field // ""
l!l
00
MC/DC0%0/1
$field // ""
$field
Truth table0%0/2
A
A= $field
Aresult
11
00
3790 0 ▶ if( $field !~ /^[a-zA-Z0-9\_]+$/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($field =~ /^[a-zA-Z0-9\_]+$/) 0 0 0
3791 {
3792 0 die( "The order field name provided contains illegal value. It must be an alphanumerical string, with possible '_' character." );
3793 }
3794 }
3795 }
3796 328 ▶ my $sql_arrays_in = ( exists( $def->{has_array} ) && ref( $def->{has_array} ) eq 'ARRAY' ? $def->{has_array} : [] );
Branch: 1 branch
BranchTrueFalseTotal
exists $def->{'has_array'} && ref $def->{'has_array'} eq 'ARRAY' ? : 204 124 328
Condition66%2/3
exists $def->{"has_array"} and ref $def->{"has_array"} eq "ARRAY"
!ll&&!rl&&r
1240204
MC/DC50%1/2
exists $def->{"has_array"} and ref $def->{"has_array"} eq "ARRAY"
exists $def->{"has_array"} ref $def->{"has_array"} eq "ARRAY"
Truth table66%2/3
A and B
A= exists $def->{"has_array"}B= ref $def->{"has_array"} eq "ARRAY"
ABresult
0X0
100
111
3797 328 my $sth;
3798 328 my $op_map =
3799 {
3800 '=' => 'IS',
3801 '!=' => 'IS NOT',
3802 };
3803 328 my $by_values = [];
3804 328 my $skeleton = [];
3805 328 my $by_keys = [];
3806 328 ▶ if( scalar( @$by ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$by) 328 0 328
3807 {
3808 328 for( @$by )
3809 {
3810 1233 ▶ return( $self->error( "Table field provided '$_' contains illegal characters." ) ) if( $_ !~ /^[a-z][a-z0-9]+(?:\_[a-z][a-z0-9]+)*$/ );
Branch: 1 branch
BranchTrueFalseTotal
unless $_ =~ /^[a-z][a-z0-9]+(?:\_[a-z][a-z0-9]+)*$/ 0 1233 1233
3811 1233 ▶ next unless( exists( $opts->{ $_ } ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts->{$_} 818 415 1233
3812 415 ▶ if( ref( $opts->{ $_ } // '' ) eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref($opts->{$_} // '') eq 'ARRAY') { } 0 415 415
Condition100%2/2
$opts->{$_} // ""
l!l
4087
MC/DC100%1/1
$opts->{$_} // ""
$opts->{$_}
Truth table100%2/2
A
A= $opts->{$_}
Aresult
11
00
3813 {
3814 0 my $and_skels = [];
3815 0 ▶ for( my $i = 0; $i < scalar( @{$opts->{ $_ }} ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$opts->{$_};}) 0 0 0
3816 {
3817 0 my $op = '=';
3818 0 my $val = $opts->{ $_ }->[$i];
3819 0 ▶ if( defined( $val ) &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{'val'}/) { } 0 0 0
elsif (defined $val and ref $val eq 'Regexp') { } 0 0 0
Condition0%0/3
defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
defined $val $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
Truth table0%0/3
A and B
A= defined $valB= $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
ABresult
0X0
100
111
3820 $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{val}/ )
3821 {
3822 0 $op = $+{op};
3823 }
3824 ▶ elsif( defined( $val ) &&
Condition0%0/3
defined $val and ref $val eq "Regexp"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and ref $val eq "Regexp"
defined $val ref $val eq "Regexp"
Truth table0%0/3
A and B
A= defined $valB= ref $val eq "Regexp"
ABresult
0X0
100
111
3825 ref( $val ) eq 'Regexp' )
3826 {
3827 0 $op = '~';
3828 0 $val =~ s/^\(\?[^\:]+\:(.*?)\)$/$1/;
3829 }
3830  
3831 0 ▶ $op = $op_map->{ $op } if( exists( $op_map->{ $op } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $op_map->{$op} 0 0 0
3832 0 ▶ if( $op eq '~' )
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq '~') { } 0 0 0
3833 {
3834 0 push( @$and_skels, "$_ REGEXP(?)" );
3835 0 push( @$by_keys, "regexp_${_}" );
3836 }
3837 else
3838 {
3839 0 push( @$and_skels, "$_ ${op} ?" );
3840 0 push( @$by_keys, "${op}${_}" );
3841 }
3842 0 ▶ push( @$by_values, defined( $val ) ? ( Scalar::Util::blessed( $val ) && overload::Method( $val => '""' ) ) ? "$val" : $val : $val );
Branch: 2 branches
BranchTrueFalseTotal
defined $val ? : 0 0 0
builtin::blessed($val) && overload::Method($val, '""') ? : 0 0 0
Condition0%0/3
builtin::blessed($val) and overload::Method($val, "\"\"")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($val) and overload::Method($val, "\"\"")
builtin::blessed($val) overload::Method($val, "\"\"")
Truth table0%0/3
A and B
A= builtin::blessed($val)B= overload::Method($val, "\"\"")
ABresult
0X0
100
111
3843 }
3844 0 push( @$skeleton, '( ' . join( ' OR ', @$and_skels ) . ' )' );
3845 }
3846 else
3847 {
3848 415 my $op = '=';
3849 415 my $val = $opts->{ $_ };
3850 415 ▶ if( defined( $val ) &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{'val'}/) { } 0 415 415
elsif (defined $val and ref $val eq 'Regexp') { } 1 421 422
Condition66%2/3
defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
!ll&&!rl&&r
74080
MC/DC0%0/2
defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
defined $val $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
Truth table66%2/3
A and B
A= defined $valB= $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
ABresult
0X0
100
111
3851 $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{val}/ )
3852 {
3853 0 $op = $+{op};
3854 }
3855 ▶ elsif( defined( $val ) &&
Condition100%3/3
defined $val and ref $val eq "Regexp"
!ll&&!rl&&r
74071
MC/DC100%2/2
defined $val and ref $val eq "Regexp"
defined $val ref $val eq "Regexp"
Truth table100%3/3
A and B
A= defined $valB= ref $val eq "Regexp"
ABresult
0X0
100
111
3856 ref( $val ) eq 'Regexp' )
3857 {
3858 1 $op = '~';
3859 1 $val =~ s/^\(\?[^\:]+\:(.*?)\)$/$1/;
3860 }
3861  
3862 415 ▶ $op = $op_map->{ $op } if( exists( $op_map->{ $op } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $op_map->{$op} 414 1 415
3863 415 ▶ if( $op eq '~' )
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq '~') { } 1 414 415
3864 {
3865 1 push( @$skeleton, "$_ REGEXP(?)" );
3866 1 push( @$by_keys, "regexp_${_}" );
3867 }
3868 else
3869 {
3870 414 push( @$skeleton, "$_ ${op} ?" );
3871 414 push( @$by_keys, "${op}${_}" );
3872 }
3873 415 ▶ push( @$by_values, defined( $val ) ? ( Scalar::Util::blessed( $val ) && overload::Method( $val => '""' ) ) ? "$val" : $val : $val );
Branch: 2 branches
BranchTrueFalseTotal
defined $val ? : 408 7 415
builtin::blessed($val) && overload::Method($val, '""') ? : 0 408 408
Condition33%1/3
builtin::blessed($val) and overload::Method($val, "\"\"")
!ll&&!rl&&r
40800
MC/DC0%0/2
builtin::blessed($val) and overload::Method($val, "\"\"")
builtin::blessed($val) overload::Method($val, "\"\"")
Truth table33%1/3
A and B
A= builtin::blessed($val)B= overload::Method($val, "\"\"")
ABresult
0X0
100
111
3874 }
3875 }
3876 }
3877 328 ▶ if( defined( $status ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $status and exists $opts->{$status}) 0 328 328
Condition66%2/3
defined $status and exists $opts->{$status}
!ll&&!rl&&r
318100
MC/DC0%0/2
defined $status and exists $opts->{$status}
defined $status exists $opts->{$status}
Truth table66%2/3
A and B
A= defined $statusB= exists $opts->{$status}
ABresult
0X0
100
111
3878 exists( $opts->{ $status } ) )
3879 {
3880 0 push( @$by, $status );
3881 0 push( @$by_values, $opts->{ $status } );
3882 0 push( @$skeleton, "${status} = ?" );
3883 0 push( @$by_keys, "=${status}" );
3884 }
3885  
3886 328 my( $has, $has_keys, $has_values );
3887 328 ▶ if( $opts->{has} && scalar( @$sql_arrays_in ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"has"} and scalar @$sql_arrays_in) 0 328 328
Condition50%1/2
$opts->{"has"} and scalar @$sql_arrays_in
!ll
3280
MC/DC0%0/1
$opts->{"has"} and scalar @$sql_arrays_in
$opts->{"has"}
Truth table50%1/2
A
A= $opts->{"has"}
Aresult
00
11
3888 {
3889 0 my $has_elems = [];
3890 0 ▶ if( ref( $opts->{has} ) eq 'HASH' )
Branch: 3 branches
BranchTrueFalseTotal
if (ref $opts->{'has'} eq 'HASH') { } 0 0 0
elsif (ref $opts->{'has'} eq 'ARRAY') { } 0 0 0
elsif (scalar @$sql_arrays_in == 1) { } 0 0 0
3891 {
3892 0 @$has_elems = %{$opts->{has}};
3893 }
3894 elsif( ref( $opts->{has} ) eq 'ARRAY' )
3895 {
3896 0 $has_elems = $opts->{has};
3897 }
3898 elsif( scalar( @$sql_arrays_in ) == 1 )
3899 {
3900 0 $has_elems = [ $sql_arrays_in->[0] => $opts->{has} ];
3901 }
3902 else
3903 {
3904 0 ▶ return( $self->error( "There are ", scalar( @$sql_arrays_in ), " fields with array. You need to specify which one you want to check for value '", ( $opts->{has} // 'undef' ), "'" ) );
Condition0%0/2
$opts->{"has"} // "undef"
l!l
00
MC/DC0%0/1
$opts->{"has"} // "undef"
$opts->{"has"}
Truth table0%0/2
A
A= $opts->{"has"}
Aresult
11
00
3905 }
3906 0 $has = [];
3907 0 $has_keys = [];
3908 0 $has_values = [];
3909 0 ▶ for( my $i = 0; $i < scalar( @$has_elems ); $i += 2 )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$has_elems) 0 0 0
3910 {
3911 0 my $f = $has_elems->[$i];
3912 0 ▶ unless( $f =~ /^[a-zA-z][a-zA-z0-9]+$/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($f =~ /^[a-zA-z][a-zA-z0-9]+$/) 0 0 0
3913 {
3914 0 return( $self->error( "Invalid field name '${f}' for table '${table}'. It should only contain alpha numeric characters." ) );
3915 }
3916 0 push( @$has_keys, $f );
3917 0 push( @$has_values, $has_elems->[$i + 1] );
3918 0 push( @$has, "EXISTS (SELECT * FROM JSON_EACH(${f}) WHERE JSON_EACH.value IS ?)" );
3919 }
3920 }
3921  
3922 328 ▶ my $by_key = scalar( @$by_keys ) ? join( '_', @$by_keys ) : '';
Branch: 1 branch
BranchTrueFalseTotal
scalar @$by_keys ? : 327 1 328
3923 328 ▶ my $sth_id = $by_key
Branch: 3 branches
BranchTrueFalseTotal
$by_key ? : 327 1 328
defined $has ? : 0 327 327
defined $has ? : 0 1 1
3924 ? "${id}_with_${by_key}" . ( defined( $has ) ? '_has_' . join( '_', @$has_keys ) : '' ) . "_order_${order}"
3925 : defined( $has )
3926 ? "${id}_with_has_" . join( '_', @$has_keys ) . "_order_${order}"
3927 : "${id}_order_${order}";
3928 328 local $" = ', ';
3929 328 local $@;
3930 328 ▶ if( $by_key || defined( $has ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($by_key or defined $has) { } 327 1 328
Condition66%2/3
$by_key or defined $has
l!l&&r!l&&!r
32701
MC/DC50%1/2
$by_key or defined $has
$by_key defined $has
Truth table66%2/3
A or B
A= $by_keyB= defined $has
ABresult
1X1
011
000
3931 {
3932 327 ▶ unless( $sth = $self->_get_cached_statement( $sth_id ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement($sth_id)) 109 218 327
3933 {
3934 109 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition50%1/2
$self->_dbh || (return $self->pass_error)
l!l
1090
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table50%1/2
A
A= $self->_dbh
Aresult
11
00
3935 $sth = eval
3936 109 ▶ {
Condition50%1/2
eval { do { $dbh->prepare("SELECT * FROM $table WHERE " . join(' AND ', @$skeleton) . (defined $has ? (scalar @$skeleton ? ' AND (' : '') . join(' OR ', @$has) . (scalar @$skeleton ? ')' : '') : '') . " ORDER BY $order") } } || (return $self->error("Unable to prepare SQL query to retrieve all $what information for fields @${by}: ", $@ || $dbh->errstr))
l!l
1090
MC/DC0%0/1
eval { do { $dbh->prepare("SELECT * FROM $table WHERE " . join(' AND ', @$skeleton) . (defined $has ? (scalar @$skeleton ? ' AND (' : '') . join(' OR ', @$has) . (scalar @$skeleton ? ')' : '') : '') . " ORDER BY $order") } } || (return $self->error("Unable to prepare SQL query to retrieve all $what information for fields @${by}: ", $@ || $dbh->errstr))
eval { do { $dbh->prepare("SELECT * FROM $table WHERE " . join(' AND ', @$skeleton) . (defined $has ? (scalar @$skeleton ? ' AND (' : '') . join(' OR ', @$has) . (scalar @$skeleton ? ')' : '') : '') . " ORDER BY $order") } }
Truth table50%1/2
A
A= eval { do { $dbh->prepare("SELECT * FROM $table WHERE " . join(' AND ', @$skeleton) . (defined $has ? (scalar @$skeleton ? ' AND (' : '') . join(' OR ', @$has) . (scalar @$skeleton ? ')' : '') : '') . " ORDER BY $order") } }
Aresult
11
00
3937 109 ▶ $dbh->prepare( "SELECT * FROM ${table} WHERE " . join( ' AND ', @$skeleton ) . ( defined( $has ) ? ( ( scalar( @$skeleton ) ? ' AND (' : '' ) . join( ' OR ', @$has ) . ( scalar( @$skeleton ) ? ')' : '' ) ) : '' ) . " ORDER BY ${order}" )
Branch: 3 branches
BranchTrueFalseTotal
defined $has ? : 0 109 109
scalar @$skeleton ? : 0 0 0
scalar @$skeleton ? : 0 0 0
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
3938 } || return( $self->error( "Unable to prepare SQL query to retrieve all ${what} information for fields @$by: ", ( $@ || $dbh->errstr ) ) );
3939 109 $self->_set_cached_statement( $sth_id => $sth );
3940 }
3941 }
3942 else
3943 {
3944 1 ▶ unless( $sth = $self->_get_cached_statement( $sth_id ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement($sth_id)) 1 0 1
3945 {
3946 1 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition50%1/2
$self->_dbh || (return $self->pass_error)
l!l
10
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table50%1/2
A
A= $self->_dbh
Aresult
11
00
3947 $sth = eval
3948 1 ▶ {
Condition50%1/2
eval { do { $dbh->prepare("SELECT * FROM $table ORDER BY $order") } } || (return $self->error("Unable to prepare SQL query to retrieve all $what information: ", $@ || $dbh->errstr))
l!l
10
MC/DC0%0/1
eval { do { $dbh->prepare("SELECT * FROM $table ORDER BY $order") } } || (return $self->error("Unable to prepare SQL query to retrieve all $what information: ", $@ || $dbh->errstr))
eval { do { $dbh->prepare("SELECT * FROM $table ORDER BY $order") } }
Truth table50%1/2
A
A= eval { do { $dbh->prepare("SELECT * FROM $table ORDER BY $order") } }
Aresult
11
00
3949 1 ▶ $dbh->prepare( "SELECT * FROM ${table} ORDER BY ${order}" )
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
3950 } || return( $self->error( "Unable to prepare SQL query to retrieve all ${what} information: ", ( $@ || $dbh->errstr ) ) );
3951 1 $self->_set_cached_statement( $sth_id => $sth );
3952 }
3953 }
3954  
3955 eval
3956 {
3957 328 ▶ $sth->execute( ( scalar( @$by_values ) ? @$by_values : () ), ( defined( $has_values ) ? @$has_values : () ) )
Branch: 3 branches
BranchTrueFalseTotal
scalar @$by_values ? : 327 1 328
defined $has_values ? : 0 328 328
$by_key ? : 0 0 0
Condition0%0/3
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
3958 328 ▶ } || return( $self->error( "Error executing SQL query '$sth->{Statement}' to retrieve all ${what}". ( $by_key ? " with fields @$by" : '' ), ": ", ( $@ || $sth->errstr ), " with SQL query: ", $sth->{Statement} ) );
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute(scalar @$by_values ? @$by_values : (), defined $has_values ? @$has_values : ()) } } or return $self->error(qq[Error executing SQL query '$sth->{"Statement"}' to retrieve all $what] . ($by_key ? " with fields @$by" : ""), ": ", $@ || $sth->errstr, " with SQL query: ", $sth->{"Statement"}) 328 0 328
3959 328 my $all = $sth->fetchall_arrayref({});
3960 328 $self->_decode_utf8( $all ) if( MISSING_AUTO_UTF8_DECODING );
3961 328 ▶ if( $all && scalar( @$sql_arrays_in ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($all and scalar @$sql_arrays_in) 204 124 328
Condition50%1/2
$all and scalar @$sql_arrays_in
!ll
0328
MC/DC0%0/1
$all and scalar @$sql_arrays_in
$all
Truth table50%1/2
A
A= $all
Aresult
00
11
3962 {
3963 204 ▶ $self->_decode_sql_arrays( $sql_arrays_in, $all ) if( $self->{decode_sql_arrays} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"decode_sql_arrays"} 204 0 204
3964 }
3965 328 ▶ if( !$all && want( 'ARRAY' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not $all and want("ARRAY")) 0 328 328
Condition33%1/3
not $all and want("ARRAY")
!ll&&!rl&&r
32800
MC/DC0%0/2
not $all and want("ARRAY")
not $all want("ARRAY")
Truth table33%1/3
not(A) and B
A= not $allB= want("ARRAY")
ABresult
0X0
100
111
3966 {
3967 0 return( [] );
3968 }
3969 328 return( $all );
3970 }
3971  
3972 sub _fetch_one
3973 647 ▶{
Subroutine _fetch_one: called CC=68 SCAR=51.2
3974 647 my $self = shift( @_ );
3975 647 ▶ my $def = shift( @_ ) || return( $self->error( "No hash definition provided." ) );
Condition50%1/2
shift @_ || (return $self->error('No hash definition provided.'))
l!l
6470
MC/DC0%0/1
shift @_ || (return $self->error('No hash definition provided.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
3976 647 ▶ return( $self->error( "Hash definition is not an hash reference." ) ) if( ref( $def ) ne 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $def ne "HASH" 0 647 647
3977 647 ▶ my $field = $def->{field} || return( $self->error( "No table field was provided." ) );
Condition50%1/2
$def->{'field'} || (return $self->error('No table field was provided.'))
l!l
6470
MC/DC0%0/1
$def->{'field'} || (return $self->error('No table field was provided.'))
$def->{'field'}
Truth table50%1/2
A
A= $def->{'field'}
Aresult
11
00
3978 647 ▶ my $what = $def->{what} || $field;
Condition33%1/3
$def->{'what'} || $field
l!l&&r!l&&!r
06470
MC/DC0%0/2
$def->{'what'} || $field
$def->{'what'} $field
Truth table33%1/3
A || B
A= $def->{'what'}B= $field
ABresult
1X1
011
000
3979 647 ▶ my $table = $def->{table} || return( $self->error( "No SQL table name was provided." ) );
Condition50%1/2
$def->{'table'} || (return $self->error('No SQL table name was provided.'))
l!l
6470
MC/DC0%0/1
$def->{'table'} || (return $self->error('No SQL table name was provided.'))
$def->{'table'}
Truth table50%1/2
A
A= $def->{'table'}
Aresult
11
00
3980 647 ▶ my $defaults = $def->{default} || {};
Condition100%2/2
$def->{'default'} || {}
l!l
37610
MC/DC100%1/1
$def->{'default'} || {}
$def->{'default'}
Truth table100%2/2
A
A= $def->{'default'}
Aresult
11
00
3981 647 my $opts = $self->_get_args_as_hash( @_ );
3982 647 ▶ return( $self->error( "No ${what} ID provided to retrieve its information." ) ) if( !exists( $opts->{ $field } ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts->{$field} 0 647 647
3983 647 ▶ my $id = ref( $opts->{ $field } ) eq 'ARRAY' ? $opts->{ $field } : [$opts->{ $field }];
Branch: 1 branch
BranchTrueFalseTotal
ref $opts->{$field} eq 'ARRAY' ? : 1 646 647
3984 647 ▶ my $sql_arrays_in = ( exists( $def->{has_array} ) && ref( $def->{has_array} ) eq 'ARRAY' ? $def->{has_array} : [] );
Branch: 1 branch
BranchTrueFalseTotal
exists $def->{'has_array'} && ref $def->{'has_array'} eq 'ARRAY' ? : 546 101 647
Condition66%2/3
exists $def->{"has_array"} and ref $def->{"has_array"} eq "ARRAY"
!ll&&!rl&&r
1010546
MC/DC50%1/2
exists $def->{"has_array"} and ref $def->{"has_array"} eq "ARRAY"
exists $def->{"has_array"} ref $def->{"has_array"} eq "ARRAY"
Truth table66%2/3
A and B
A= exists $def->{"has_array"}B= ref $def->{"has_array"} eq "ARRAY"
ABresult
0X0
100
111
3985 my $requires = exists( $def->{requires} ) && ref( $def->{requires} ) eq 'ARRAY'
3986 ? $def->{requires}
3987 647 ▶ : [];
Branch: 1 branch
BranchTrueFalseTotal
exists $def->{'requires'} && ref $def->{'requires'} eq 'ARRAY' ? : 128 519 647
Condition66%2/3
exists $def->{"requires"} and ref $def->{"requires"} eq "ARRAY"
!ll&&!rl&&r
5190128
MC/DC50%1/2
exists $def->{"requires"} and ref $def->{"requires"} eq "ARRAY"
exists $def->{"requires"} ref $def->{"requires"} eq "ARRAY"
Truth table66%2/3
A and B
A= exists $def->{"requires"}B= ref $def->{"requires"} eq "ARRAY"
ABresult
0X0
100
111
3988 # my $requires_key = scalar( @$requires ) ? join( '_', @$requires ) : '';
3989 647 my $required_val = [];
3990 647 my $required_skel = [];
3991 647 my $required_keys = [];
3992 # In SQLite, the expression '= NULL' does not work, and we need to use 'IS NULL'
3993 647 my $op_map =
3994 {
3995 '=' => 'IS',
3996 '!=' => 'IS NOT',
3997 };
3998  
3999 647 for( @$requires )
4000 {
4001 217 ▶ return( $self->error( "Table field provided '$_' contains illegal characters." ) ) if( $_ !~ /^[a-z][a-z0-9]+(?:\_[a-z][a-z0-9]+)*$/ );
Branch: 1 branch
BranchTrueFalseTotal
unless $_ =~ /^[a-z][a-z0-9]+(?:\_[a-z][a-z0-9]+)*$/ 0 217 217
4002 217 ▶ $opts->{ $_ } = $defaults->{ $_ } if( !exists( $opts->{ $_ } ) && exists( $defaults->{ $_ } ) );
Branch: 1 branch
BranchTrueFalseTotal
if not exists $opts->{$_} and exists $defaults->{$_} 28 189 217
Condition100%3/3
not exists $opts->{$_} and exists $defaults->{$_}
!ll&&!rl&&r
188128
MC/DC100%2/2
not exists $opts->{$_} and exists $defaults->{$_}
not exists $opts->{$_} exists $defaults->{$_}
Truth table100%3/3
not(A) and B
A= not exists $opts->{$_}B= exists $defaults->{$_}
ABresult
0X0
100
111
4003 217 ▶ if( !exists( $opts->{ $_ } ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $opts->{$_}) 1 216 217
4004 {
4005 1 return( $self->error( "No value for $_ was provided." ) );
4006 }
4007  
4008 216 ▶ if( ref( $opts->{ $_ } // '' ) eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref($opts->{$_} // '') eq 'ARRAY') { } 1 215 216
Condition100%2/2
$opts->{$_} // ""
l!l
18828
MC/DC100%1/1
$opts->{$_} // ""
$opts->{$_}
Truth table100%2/2
A
A= $opts->{$_}
Aresult
11
00
4009 {
4010 1 my $and_skels = [];
4011 1 ▶ for( my $i = 0; $i < scalar( @{$opts->{ $_ }} ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$opts->{$_};}) 2 1 3
4012 {
4013 2 my $op = '=';
4014 2 my $val = $opts->{ $_ }->[$i];
4015 2 ▶ if( defined( $val ) &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{'val'}/) { } 2 0 2
elsif (defined $val and ref $val eq 'Regexp') { } 0 0 0
Condition33%1/3
defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
!ll&&!rl&&r
002
MC/DC0%0/2
defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
defined $val $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
Truth table33%1/3
A and B
A= defined $valB= $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
ABresult
0X0
100
111
4016 # $opts->{ $_ }->[$i] =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=)[[:blank:]\h]*(?<dt>\-?\d+.*?)$/$+{dt}/ )
4017 $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{val}/ )
4018 {
4019 2 $op = $+{op};
4020 }
4021 ▶ elsif( defined( $val ) &&
Condition0%0/3
defined $val and ref $val eq "Regexp"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and ref $val eq "Regexp"
defined $val ref $val eq "Regexp"
Truth table0%0/3
A and B
A= defined $valB= ref $val eq "Regexp"
ABresult
0X0
100
111
4022 ref( $val ) eq 'Regexp' )
4023 {
4024 0 $op = '~';
4025 0 $val =~ s/^\(\?[^\:]+\:(.*?)\)$/$1/;
4026 }
4027  
4028 2 ▶ $op = $op_map->{ $op } if( exists( $op_map->{ $op } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $op_map->{$op} 0 2 2
4029 2 ▶ if( $op eq '~' )
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq '~') { } 0 2 2
4030 {
4031 0 push( @$and_skels, "$_ REGEXP(?)" );
4032 0 push( @$required_keys, "regexp_${_}" );
4033 }
4034 else
4035 {
4036 2 push( @$and_skels, "$_ ${op} ?" );
4037 2 push( @$required_keys, "${op}${_}" );
4038 }
4039 2 ▶ push( @$required_val, defined( $val ) ? ( Scalar::Util::blessed( $val ) && overload::Method( $val => '""' ) ) ? "$val" : $val : $val );
Branch: 2 branches
BranchTrueFalseTotal
defined $val ? : 2 0 2
builtin::blessed($val) && overload::Method($val, '""') ? : 0 2 2
Condition33%1/3
builtin::blessed($val) and overload::Method($val, "\"\"")
!ll&&!rl&&r
200
MC/DC0%0/2
builtin::blessed($val) and overload::Method($val, "\"\"")
builtin::blessed($val) overload::Method($val, "\"\"")
Truth table33%1/3
A and B
A= builtin::blessed($val)B= overload::Method($val, "\"\"")
ABresult
0X0
100
111
4040 }
4041 1 push( @$required_skel, '( ' . join( ' OR ', @$and_skels ) . ' )' );
4042 }
4043 else
4044 {
4045 215 my $op = '=';
4046 215 my $val = $opts->{ $_ };
4047 215 ▶ if( defined( $val ) &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{'val'}/) { } 0 215 215
elsif (defined $val and ref $val eq 'Regexp') { } 0 243 243
Condition66%2/3
defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
!ll&&!rl&&r
281870
MC/DC0%0/2
defined $val and $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
defined $val $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
Truth table66%2/3
A and B
A= defined $valB= $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
ABresult
0X0
100
111
4048 # $opts->{ $_ } =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=\~)[[:blank:]\h]*(?<dt>\-?\d+.*?)$/$+{dt}/ )
4049 $val =~ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{val}/ )
4050 {
4051 0 $op = $+{op};
4052 }
4053 ▶ elsif( defined( $val ) &&
Condition66%2/3
defined $val and ref $val eq "Regexp"
!ll&&!rl&&r
281870
MC/DC0%0/2
defined $val and ref $val eq "Regexp"
defined $val ref $val eq "Regexp"
Truth table66%2/3
A and B
A= defined $valB= ref $val eq "Regexp"
ABresult
0X0
100
111
4054 ref( $val ) eq 'Regexp' )
4055 {
4056 0 $op = '~';
4057 0 $val =~ s/^\(\?[^\:]+\:(.*?)\)$/$1/;
4058 }
4059  
4060 215 ▶ $op = $op_map->{ $op } if( exists( $op_map->{ $op } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $op_map->{$op} 215 0 215
4061 215 ▶ if( $op eq '~' )
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq '~') { } 0 215 215
4062 {
4063 0 push( @$required_skel, "$_ REGEXP(?)" );
4064 0 push( @$required_keys, "regexp_${_}" );
4065 }
4066 else
4067 {
4068 215 push( @$required_skel, "$_ ${op} ?" );
4069 215 push( @$required_keys, "${op}${_}" );
4070 }
4071 215 ▶ push( @$required_val, defined( $val ) ? ( Scalar::Util::blessed( $val ) && overload::Method( $val => '""' ) ) ? "$val" : $val : $val );
Branch: 2 branches
BranchTrueFalseTotal
defined $val ? : 187 28 215
builtin::blessed($val) && overload::Method($val, '""') ? : 0 187 187
Condition33%1/3
builtin::blessed($val) and overload::Method($val, "\"\"")
!ll&&!rl&&r
18700
MC/DC0%0/2
builtin::blessed($val) and overload::Method($val, "\"\"")
builtin::blessed($val) overload::Method($val, "\"\"")
Truth table33%1/3
A and B
A= builtin::blessed($val)B= overload::Method($val, "\"\"")
ABresult
0X0
100
111
4072 }
4073 }
4074 646 ▶ my $requires_key = scalar( @$required_keys ) ? join( '_', @$required_keys ) : '';
Branch: 1 branch
BranchTrueFalseTotal
scalar @$required_keys ? : 127 519 646
4075 646 my $field_val = [];
4076 646 my $field_skel = [];
4077 646 my $field_keys = [];
4078 646 for( @$id )
4079 {
4080 647 my $op = '=';
4081 647 ▶ if( defined( $_ ) &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_ and s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{'val'}/) { } 1 646 647
elsif (defined $_ and ref $_ eq 'Regexp') { } 0 646 646
Condition66%2/3
defined $_ and s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
!ll&&!rl&&r
06461
MC/DC50%1/2
defined $_ and s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
defined $_ s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
Truth table66%2/3
A and B
A= defined $_B= s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{"val"}/
ABresult
0X0
100
111
4082 s/^[[:blank:]\h]*(?<op>\<|\<=|\>|\>=|=|\!=|\~)[[:blank:]\h]*(?<val>.*?)$/$+{val}/ )
4083 {
4084 1 $op = $+{op};
4085 }
4086 ▶ elsif( defined( $_ ) &&
Condition33%1/3
defined $_ and ref $_ eq "Regexp"
!ll&&!rl&&r
06460
MC/DC0%0/2
defined $_ and ref $_ eq "Regexp"
defined $_ ref $_ eq "Regexp"
Truth table33%1/3
A and B
A= defined $_B= ref $_ eq "Regexp"
ABresult
0X0
100
111
4087 ref( $_ ) eq 'Regexp' )
4088 {
4089 0 $op = '~';
4090 0 s/^\(\?[^\:]+\:(.*?)\)$/$1/;
4091 }
4092  
4093 647 ▶ $op = $op_map->{ $op } if( exists( $op_map->{ $op } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $op_map->{$op} 646 1 647
4094 647 ▶ if( $op eq '~' )
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq '~') { } 1 646 647
4095 {
4096 1 push( @$field_skel, "${field} REGEXP(?)" );
4097 1 push( @$field_keys, "regexp_field" );
4098 }
4099 else
4100 {
4101 646 push( @$field_skel, "${field} ${op} ?" );
4102 646 push( @$field_keys, "${op}${field}" );
4103 }
4104 647 ▶ push( @$field_val, defined( $_ ) ? ( Scalar::Util::blessed( $_ ) && overload::Method( $_ => '""' ) ) ? "$_" : $_ : $_ );
Branch: 2 branches
BranchTrueFalseTotal
defined $_ ? : 647 0 647
builtin::blessed($_) && overload::Method($_, '""') ? : 486 161 647
Condition66%2/3
builtin::blessed($_) and overload::Method($_, "\"\"")
!ll&&!rl&&r
1610486
MC/DC50%1/2
builtin::blessed($_) and overload::Method($_, "\"\"")
builtin::blessed($_) overload::Method($_, "\"\"")
Truth table66%2/3
A and B
A= builtin::blessed($_)B= overload::Method($_, "\"\"")
ABresult
0X0
100
111
4105 }
4106 646 ▶ my $sth_id = ( $def->{id} ? $def->{id} . '_' : '' ) . join( '_', @$field_keys );
Branch: 1 branch
BranchTrueFalseTotal
$def->{'id'} ? : 644 2 646
4107 646 ▶ $sth_id .= '_' . $requires_key if( $requires_key );
Branch: 1 branch
BranchTrueFalseTotal
if $requires_key 127 519 646
4108 646 my $sth;
4109 646 local $@;
4110 646 ▶ unless( $sth = $self->_get_cached_statement( $sth_id ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement($sth_id)) 75 571 646
4111 {
4112 75 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition50%1/2
$self->_dbh || (return $self->pass_error)
l!l
750
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table50%1/2
A
A= $self->_dbh
Aresult
11
00
4113 $sth = eval
4114 75 ▶ {
Condition50%1/2
eval { do { $dbh->prepare("SELECT * FROM $table WHERE (" . join(' OR ', @$field_skel) . ') ' . (scalar @$required_skel ? ' AND ' . join(' AND ', @$required_skel) : '') . ($def->{'multi'} ? ' ORDER BY rowid' : '')) } } || (return $self->error("Unable to prepare SQL query with statement ID $sth_id to retrieve a $what information: ", $@ || $dbh->errstr))
l!l
750
MC/DC0%0/1
eval { do { $dbh->prepare("SELECT * FROM $table WHERE (" . join(' OR ', @$field_skel) . ') ' . (scalar @$required_skel ? ' AND ' . join(' AND ', @$required_skel) : '') . ($def->{'multi'} ? ' ORDER BY rowid' : '')) } } || (return $self->error("Unable to prepare SQL query with statement ID $sth_id to retrieve a $what information: ", $@ || $dbh->errstr))
eval { do { $dbh->prepare("SELECT * FROM $table WHERE (" . join(' OR ', @$field_skel) . ') ' . (scalar @$required_skel ? ' AND ' . join(' AND ', @$required_skel) : '') . ($def->{'multi'} ? ' ORDER BY rowid' : '')) } }
Truth table50%1/2
A
A= eval { do { $dbh->prepare("SELECT * FROM $table WHERE (" . join(' OR ', @$field_skel) . ') ' . (scalar @$required_skel ? ' AND ' . join(' AND ', @$required_skel) : '') . ($def->{'multi'} ? ' ORDER BY rowid' : '')) } }
Aresult
11
00
4115 75 ▶ $dbh->prepare( "SELECT * FROM ${table} WHERE (" . join( ' OR ', @$field_skel ) . ') ' . ( scalar( @$required_skel ) ? ' AND ' . join( ' AND ', @$required_skel ) : '' ) . ( $def->{multi} ? ' ORDER BY rowid' : '' ) )
Branch: 2 branches
BranchTrueFalseTotal
scalar @$required_skel ? : 42 33 75
$def->{'multi'} ? : 0 75 75
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
4116 } || return( $self->error( "Unable to prepare SQL query with statement ID ${sth_id} to retrieve a ${what} information: ", ( $@ || $dbh->errstr ) ) );
4117 75 $self->_set_cached_statement( $sth_id => $sth );
4118 }
4119  
4120 eval
4121 {
4122 646 ▶ $sth->execute( @$field_val, ( scalar( @$required_val ) ? @$required_val : () ) );
Branch: 1 branch
BranchTrueFalseTotal
scalar @$required_val ? : 127 519 646
Condition0%0/3
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
4123 646 ▶ } || return( $self->error( "Error executing SQL query '$sth->{Statement}' with statement ID ${sth_id} to retrieve a ${what} information:", ( $@ || $sth->errstr ), " with SQL query: ", $sth->{Statement} ) );
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute(@$field_val, scalar @$required_val ? @$required_val : ()) } } or return $self->error(qq[Error executing SQL query '$sth->{"Statement"}' with statement ID $sth_id to retrieve a $what information:], $@ || $sth->errstr, " with SQL query: ", $sth->{"Statement"}) 646 0 646
4124 646 ▶ my $ref = ( $def->{multi} || scalar( @$id ) > 1 ) ? $sth->fetchall_arrayref({}) : $sth->fetchrow_hashref;
Branch: 1 branch
BranchTrueFalseTotal
$def->{'multi'} || scalar @$id > 1 ? : 1 645 646
Condition66%2/3
$def->{"multi"} or scalar @$id > 1
l!l&&r!l&&!r
01645
MC/DC50%1/2
$def->{"multi"} or scalar @$id > 1
$def->{"multi"} scalar @$id > 1
Truth table66%2/3
A or B
A= $def->{"multi"}B= scalar @$id > 1
ABresult
1X1
011
000
4125 646 $self->_decode_utf8( $ref ) if( MISSING_AUTO_UTF8_DECODING );
4126 646 ▶ if( $ref && scalar( @$sql_arrays_in ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($ref and scalar @$sql_arrays_in) 510 136 646
Condition100%2/2
$ref and scalar @$sql_arrays_in
!ll
45601
MC/DC100%1/1
$ref and scalar @$sql_arrays_in
$ref
Truth table100%2/2
A
A= $ref
Aresult
00
11
4127 {
4128 510 ▶ $self->_decode_sql_arrays( $sql_arrays_in, $ref ) if( $self->{decode_sql_arrays} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"decode_sql_arrays"} 510 0 510
4129 }
4130 646 ▶ if( !$ref && want( 'HASH' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not $ref and want("HASH")) 0 646 646
Condition66%2/3
not $ref and want("HASH")
!ll&&!rl&&r
601450
MC/DC0%0/2
not $ref and want("HASH")
not $ref want("HASH")
Truth table66%2/3
not(A) and B
A= not $refB= want("HASH")
ABresult
0X0
100
111
4131 {
4132 0 return( {} );
4133 }
4134 646 return( $ref );
4135 }
4136  
4137 sub _get_cached_statement
4138 1001 ▶{
Subroutine _get_cached_statement: called CC=13 SCAR=28.5
4139 1001 my $self = shift( @_ );
4140 1001 my $id = shift( @_ );
4141 1001 ▶ die( "No statement ID was provided to get its cached object." ) if( !length( $id // '' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length($id // "") 0 1001 1001
Condition50%1/2
$id // ""
l!l
10010
MC/DC0%0/1
$id // ""
$id
Truth table50%1/2
A
A= $id
Aresult
11
00
4142 1001 ▶ my $file = $self->datafile || $DB_FILE;
Condition33%1/3
$self->datafile || $Locale::Unicode::Data::DB_FILE
l!l&&r!l&&!r
100100
MC/DC0%0/2
$self->datafile || $Locale::Unicode::Data::DB_FILE
$self->datafile $Locale::Unicode::Data::DB_FILE
Truth table33%1/3
A || B
A= $self->datafileB= $Locale::Unicode::Data::DB_FILE
ABresult
1X1
011
000
4143 1001 ▶ my $tid = ( $Config{useithreads} && $INC{'threads.pm'} && threads->can('tid') ) ? threads->tid() : $$;
Branch: 1 branch
BranchTrueFalseTotal
$Locale::Unicode::Data::Config{'useithreads'} && $INC{'threads.pm'} && 'threads'->can('tid') ? : 0 1001 1001
Condition33%2/6
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"} and "threads"->can("tid")
!ll&&!rl&&r
100100
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"}
!ll&&!rl&&r
100100
MC/DC0%0/3
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"} and "threads"->can("tid")
$Locale::Unicode::Data::Config{"useithreads"} $INC{"threads.pm"} "threads"->can("tid")
Truth table25%1/4
A and B and C
A= $Locale::Unicode::Data::Config{"useithreads"}B= $INC{"threads.pm"}C= "threads"->can("tid")
ABCresult
0XX0
10X0
1100
1111
4144 1001 ▶ $STHS->{ $tid } //= {};
Condition100%2/2
$Locale::Unicode::Data::STHS->{$tid} //= {}
l!l
9965
MC/DC100%1/1
$Locale::Unicode::Data::STHS->{$tid} //= {}
$Locale::Unicode::Data::STHS->{$tid}
Truth table100%2/2
A
A= $Locale::Unicode::Data::STHS->{$tid}
Aresult
11
00
4145 1001 ▶ $STHS->{ $tid }->{ $file } //= {};
Condition100%2/2
$Locale::Unicode::Data::STHS->{$tid}{$file} //= {}
l!l
9965
MC/DC100%1/1
$Locale::Unicode::Data::STHS->{$tid}{$file} //= {}
$Locale::Unicode::Data::STHS->{$tid}{$file}
Truth table100%2/2
A
A= $Locale::Unicode::Data::STHS->{$tid}{$file}
Aresult
11
00
4146 1001 my $sth = $STHS->{ $tid }->{ $file }->{ $id };
4147 1001 ▶ if( exists( $STHS->{ $tid }->{ $file }->{ $id } ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and defined $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and builtin::blessed($Locale::Unicode::Data::STHS->{$tid}{$file}{$id}) and $Locale::Unicode::Data::STHS->{$tid}{$file}{$id}->isa("DBI::st")) 793 208 1001
Condition66%6/9
exists $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and defined $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and builtin::blessed($Locale::Unicode::Data::STHS->{$tid}{$file}{$id}) and $Locale::Unicode::Data::STHS->{$tid}{$file}{$id}->isa("DBI::st")
!ll&&!rl&&r
2080793
exists $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and defined $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and builtin::blessed($Locale::Unicode::Data::STHS->{$tid}{$file}{$id})
!ll&&!rl&&r
2080793
exists $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and defined $Locale::Unicode::Data::STHS->{$tid}{$file}{$id}
!ll&&!rl&&r
2080793
MC/DC25%1/4
exists $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and defined $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} and builtin::blessed($Locale::Unicode::Data::STHS->{$tid}{$file}{$id}) and $Locale::Unicode::Data::STHS->{$tid}{$file}{$id}->isa("DBI::st")
exists $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} defined $Locale::Unicode::Data::STHS->{$tid}{$file}{$id} builtin::blessed($Locale::Unicode::Data::STHS->{$tid}{$file}{$id}) $Locale::Unicode::Data::STHS->{$tid}{$file}{$id}->isa("DBI::st")
Truth table40%2/5
A and B and C and D
A= exists $Locale::Unicode::Data::STHS->{$tid}{$file}{$id}B= defined $Locale::Unicode::Data::STHS->{$tid}{$file}{$id}C= builtin::blessed($Locale::Unicode::Data::STHS->{$tid}{$file}{$id})D= $Locale::Unicode::Data::STHS->{$tid}{$file}{$id}->isa("DBI::st")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
4148 defined( $STHS->{ $tid }->{ $file }->{ $id } ) &&
4149 Scalar::Util::blessed( $STHS->{ $tid }->{ $file }->{ $id } ) &&
4150 $STHS->{ $tid }->{ $file }->{ $id }->isa( 'DBI::st' ) )
4151 {
4152 793 return( $STHS->{ $tid }->{ $file }->{ $id } );
4153 }
4154 208 return;
4155 }
4156  
4157 sub _get_metadata
4158 1 ▶{
Subroutine _get_metadata: called CC=9 SCAR=25.6
4159 1 my $self = shift( @_ );
4160 1 ▶ my $prop = shift( @_ ) || die( "No metadata property provided." );
Condition50%1/2
shift @_ || die('No metadata property provided.')
l!l
10
MC/DC0%0/1
shift @_ || die('No metadata property provided.')
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
4161 1 ▶ my $dbh = $self->_dbh || return( $self->pass_error );
Condition50%1/2
$self->_dbh || (return $self->pass_error)
l!l
10
MC/DC0%0/1
$self->_dbh || (return $self->pass_error)
$self->_dbh
Truth table50%1/2
A
A= $self->_dbh
Aresult
11
00
4162 1 my $sth;
4163 1 ▶ unless( $sth = $self->_get_cached_statement( 'cldr_metadata' ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($sth = $self->_get_cached_statement("cldr_metadata")) 1 0 1
4164 {
4165 $sth = eval
4166 1 ▶ {
Condition50%1/2
eval { do { $dbh->prepare('SELECT value FROM metainfos WHERE property = ?') } } || (return $self->error('Unable to prepare query to get the CLDR built datetime from the SQLite database at ', $self->datafile, ': ', $@ || $dbh->errstr))
l!l
10
MC/DC0%0/1
eval { do { $dbh->prepare('SELECT value FROM metainfos WHERE property = ?') } } || (return $self->error('Unable to prepare query to get the CLDR built datetime from the SQLite database at ', $self->datafile, ': ', $@ || $dbh->errstr))
eval { do { $dbh->prepare('SELECT value FROM metainfos WHERE property = ?') } }
Truth table50%1/2
A
A= eval { do { $dbh->prepare('SELECT value FROM metainfos WHERE property = ?') } }
Aresult
11
00
4167 1 ▶ $dbh->prepare( "SELECT value FROM metainfos WHERE property = ?" )
Condition0%0/3
$@ || $dbh->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $dbh->errstr
$@ $dbh->errstr
Truth table0%0/3
A || B
A= $@B= $dbh->errstr
ABresult
1X1
011
000
4168 } || return( $self->error( "Unable to prepare query to get the CLDR built datetime from the SQLite database at ", $self->datafile, ": ", ( $@ || $dbh->errstr ) ) );
4169 1 $self->_set_cached_statement( cldr_metadata => $sth );
4170 }
4171  
4172 1 local $@;
4173 eval
4174 1 ▶ {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $sth->execute($prop) } } or return $self->error("Unable to execute query to get the CLDR property '${prop}' from the SQLite database at ", $self->datafile, ": ", $@ || $sth->errstr) 1 0 1
4175 1 ▶ $sth->execute( $prop );
Condition0%0/3
$@ || $sth->errstr
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ || $sth->errstr
$@ $sth->errstr
Truth table0%0/3
A || B
A= $@B= $sth->errstr
ABresult
1X1
011
000
4176 } || return( $self->error( "Unable to execute query to get the CLDR property '${prop}' from the SQLite database at ", $self->datafile, ": ", ( $@ || $sth->errstr ) ) );
4177 1 my $ref = $sth->fetchrow_arrayref;
4178 1 $self->_decode_utf8( $ref ) if( MISSING_AUTO_UTF8_DECODING );
4179 1 ▶ return( '' ) if( !$ref );
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 1 1
4180 1 return( $ref->[0] );
4181 }
4182  
4183 sub _locale_object
4184 1381 ▶{
Subroutine _locale_object: called CC=5 SCAR=16.6
4185 1381 my $self = shift( @_ );
4186 1381 ▶ my $locale = shift( @_ ) ||
Condition50%1/2
shift @_ || (return $self->error('No locale provided to ensure a Locale::Unicode.'))
l!l
13810
MC/DC0%0/1
shift @_ || (return $self->error('No locale provided to ensure a Locale::Unicode.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
4187 return( $self->error( "No locale provided to ensure a Locale::Unicode." ) );
4188 1381 ▶ unless( Scalar::Util::blessed( $locale ) &&
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($locale) and $locale->isa("Locale::Unicode")) 1370 11 1381
Condition66%2/3
builtin::blessed($locale) and $locale->isa("Locale::Unicode")
!ll&&!rl&&r
1370011
MC/DC50%1/2
builtin::blessed($locale) and $locale->isa("Locale::Unicode")
builtin::blessed($locale) $locale->isa("Locale::Unicode")
Truth table66%2/3
A and B
A= builtin::blessed($locale)B= $locale->isa("Locale::Unicode")
ABresult
0X0
100
111
4189 $locale->isa( 'Locale::Unicode' ) )
4190 {
4191 1370 ▶ $locale = Locale::Unicode->new( $locale ) ||
Condition50%1/2
'Locale::Unicode'->new($locale) || (return $self->pass_error('Locale::Unicode'->error))
l!l
13700
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
4192 return( $self->pass_error( Locale::Unicode->error ) );
4193 }
4194 1381 return( $locale );
4195 }
4196  
4197 # Calls a data method for resolve(). Returns a two-element list: whether data was found
4198 # (or undef on error), and the data itself.
4199 sub _resolve_fetch
4200 14 ▶{
Subroutine _resolve_fetch: called CC=7 SCAR=19.7
4201 14 my( $self, $meth, $def, $keys, $locale ) = @_;
4202 # Clears any previous error, so that an undefined value can be distinguished from an error.
4203 14 $self->{error} = undef;
4204 14 my $res = $self->$meth( %$keys, locale => $locale );
4205 14 ▶ if( !defined( $res ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $res) 2 12 14
4206 {
4207 2 ▶ return if( defined( $self->{error} ) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"error"} 0 2 2
4208 2 return( 0, $res );
4209 }
4210 12 ▶ return( ( $def->{all} ? ( ref( $res ) eq 'ARRAY' && scalar( @$res ) ) : ( ref( $res ) eq 'HASH' && scalar( keys( %$res ) ) ) ) ? 1 : 0, $res );
Branch: 2 branches
BranchTrueFalseTotal
($def->{'all'} ? ref $res eq 'ARRAY' && scalar @$res : ref $res eq 'HASH' && scalar keys %$res) ? : 5 7 12
$def->{'all'} ? : 11 1 12
Condition50%2/4
ref $res eq "ARRAY" and scalar @$res
!ll
011
ref $res eq "HASH" and scalar keys %$res
!ll
01
MC/DC0%0/1
ref $res eq "ARRAY" and scalar @$res
ref $res eq "ARRAY"
MC/DC0%0/1
ref $res eq "HASH" and scalar keys %$res
ref $res eq "HASH"
Truth table50%1/2
A
A= ref $res eq "ARRAY"
Aresult
00
11
Truth table50%1/2
A
A= ref $res eq "HASH"
Aresult
00
11
4211 }
4212  
4213 sub _set_cached_statement
4214 208 ▶{
Subroutine _set_cached_statement: called CC=11 SCAR=30.7
4215 208 my $self = shift( @_ );
4216 208 my $id = shift( @_ );
4217 208 my $sth = shift( @_ );
4218 208 ▶ die( "No statement ID was provided to cache its object." ) if( !length( $id // '' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length($id // "") 0 208 208
Condition50%1/2
$id // ""
l!l
2080
MC/DC0%0/1
$id // ""
$id
Truth table50%1/2
A
A= $id
Aresult
11
00
4219 208 ▶ if( !$sth )
Branch: 2 branches
BranchTrueFalseTotal
if (not $sth) { } 0 208 208
elsif (not builtin::blessed($sth) && $sth->isa('DBI::st')) { } 0 208 208
4220 {
4221 0 die( "No DBI statement handler was provided to cache with ID '${id}'" );
4222 }
4223 ▶ elsif( !Scalar::Util::blessed( $sth ) ||
Condition33%1/3
builtin::blessed($sth) && $sth->isa('DBI::st')
!ll&&!rl&&r
00208
MC/DC0%0/2
builtin::blessed($sth) && $sth->isa('DBI::st')
builtin::blessed($sth) $sth->isa('DBI::st')
Truth table33%1/3
A && B
A= builtin::blessed($sth)B= $sth->isa('DBI::st')
ABresult
0X0
100
111
4224 !$sth->isa( 'DBI::st' ) )
4225 {
4226 0 die( "Value provided (", overload::StrVal( $sth ), ") is not a DBI statement object." );
4227 }
4228 208 ▶ my $file = $self->datafile || $DB_FILE;
Condition33%1/3
$self->datafile || $Locale::Unicode::Data::DB_FILE
l!l&&r!l&&!r
20800
MC/DC0%0/2
$self->datafile || $Locale::Unicode::Data::DB_FILE
$self->datafile $Locale::Unicode::Data::DB_FILE
Truth table33%1/3
A || B
A= $self->datafileB= $Locale::Unicode::Data::DB_FILE
ABresult
1X1
011
000
4229 208 ▶ my $tid = ( $Config{useithreads} && $INC{'threads.pm'} && threads->can('tid') ) ? threads->tid() : $$;
Branch: 1 branch
BranchTrueFalseTotal
$Locale::Unicode::Data::Config{'useithreads'} && $INC{'threads.pm'} && 'threads'->can('tid') ? : 0 208 208
Condition33%2/6
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"} and "threads"->can("tid")
!ll&&!rl&&r
20800
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"}
!ll&&!rl&&r
20800
MC/DC0%0/3
$Locale::Unicode::Data::Config{"useithreads"} and $INC{"threads.pm"} and "threads"->can("tid")
$Locale::Unicode::Data::Config{"useithreads"} $INC{"threads.pm"} "threads"->can("tid")
Truth table25%1/4
A and B and C
A= $Locale::Unicode::Data::Config{"useithreads"}B= $INC{"threads.pm"}C= "threads"->can("tid")
ABCresult
0XX0
10X0
1100
1111
4230 208 ▶ $STHS->{ $tid }->{ $file } //= {};
Condition50%1/2
$Locale::Unicode::Data::STHS->{$tid}{$file} //= {}
l!l
2080
MC/DC0%0/1
$Locale::Unicode::Data::STHS->{$tid}{$file} //= {}
$Locale::Unicode::Data::STHS->{$tid}{$file}
Truth table50%1/2
A
A= $Locale::Unicode::Data::STHS->{$tid}{$file}
Aresult
11
00
4231 208 $STHS->{ $tid }->{ $file }->{ $id } = $sth;
4232 208 return( $sth );
4233 }
4234  
4235 sub _set_get_prop
4236 1431 ▶{
Subroutine _set_get_prop: called CC=34 SCAR=57.5
4237 1431 my $self = shift( @_ );
4238 1431 ▶ my $field = shift( @_ ) ||
Condition50%1/2
shift @_ || (return $self->error('No field was provided.'))
l!l
14310
MC/DC0%0/1
shift @_ || (return $self->error('No field was provided.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
4239 return( $self->error( "No field was provided." ) );
4240 1431 my( $re, $type, $isa );
4241 1431 ▶ if( ref( $field ) eq 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $field eq "HASH") 1 1430 1431
4242 {
4243 1 my $def = $field;
4244 1 ▶ $field = $def->{field} || die( "No 'field' property was provided in the field dictionary hash reference." );
Condition50%1/2
$def->{'field'} || die(q[No 'field' property was provided in the field dictionary hash reference.])
l!l
10
MC/DC0%0/1
$def->{'field'} || die(q[No 'field' property was provided in the field dictionary hash reference.])
$def->{'field'}
Truth table50%1/2
A
A= $def->{'field'}
Aresult
11
00
4245 1 ▶ if( exists( $def->{regexp} ) &&
Branch: 2 branches
BranchTrueFalseTotal
if (exists $def->{'regexp'} and defined $def->{'regexp'} and ref $def->{'regexp'} eq 'Regexp') { } 0 1 1
elsif (exists $def->{'type'} and defined $def->{'type'} and length $def->{'type'}) { } 1 0 1
Condition33%2/6
exists $def->{"regexp"} and defined $def->{"regexp"} and ref $def->{"regexp"} eq "Regexp"
!ll&&!rl&&r
100
exists $def->{"regexp"} and defined $def->{"regexp"}
!ll&&!rl&&r
100
MC/DC0%0/3
exists $def->{"regexp"} and defined $def->{"regexp"} and ref $def->{"regexp"} eq "Regexp"
exists $def->{"regexp"} defined $def->{"regexp"} ref $def->{"regexp"} eq "Regexp"
Truth table25%1/4
A and B and C
A= exists $def->{"regexp"}B= defined $def->{"regexp"}C= ref $def->{"regexp"} eq "Regexp"
ABCresult
0XX0
10X0
1100
1111
4246 defined( $def->{regexp} ) &&
4247 ref( $def->{regexp} ) eq 'Regexp' )
4248 {
4249 0 $re = $def->{regexp};
4250 }
4251 ▶ elsif( exists( $def->{type} ) &&
Condition33%2/6
exists $def->{"type"} and defined $def->{"type"} and length $def->{"type"}
!ll&&!rl&&r
001
exists $def->{"type"} and defined $def->{"type"}
!ll&&!rl&&r
001
MC/DC0%0/3
exists $def->{"type"} and defined $def->{"type"} and length $def->{"type"}
exists $def->{"type"} defined $def->{"type"} length $def->{"type"}
Truth table25%1/4
A and B and C
A= exists $def->{"type"}B= defined $def->{"type"}C= length $def->{"type"}
ABCresult
0XX0
10X0
1100
1111
4252 defined( $def->{type} ) &&
4253 length( $def->{type} ) )
4254 {
4255 1 $type = $def->{type};
4256 }
4257 1 ▶ if( exists( $def->{isa} ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $def->{"isa"} and defined $def->{"isa"} and length $def->{"isa"}) 0 1 1
Condition33%2/6
exists $def->{"isa"} and defined $def->{"isa"} and length $def->{"isa"}
!ll&&!rl&&r
100
exists $def->{"isa"} and defined $def->{"isa"}
!ll&&!rl&&r
100
MC/DC0%0/3
exists $def->{"isa"} and defined $def->{"isa"} and length $def->{"isa"}
exists $def->{"isa"} defined $def->{"isa"} length $def->{"isa"}
Truth table25%1/4
A and B and C
A= exists $def->{"isa"}B= defined $def->{"isa"}C= length $def->{"isa"}
ABCresult
0XX0
10X0
1100
1111
4258 defined( $def->{isa} ) &&
4259 length( $def->{isa} ) )
4260 {
4261 0 $isa = $def->{isa};
4262 }
4263 }
4264 1431 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1430 1431
4265 {
4266 1 my $val = shift( @_ );
4267 1 ▶ if( defined( $val ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val and length $val) 1 0 1
Condition33%1/3
defined $val and length $val
!ll&&!rl&&r
001
MC/DC0%0/2
defined $val and length $val
defined $val length $val
Truth table33%1/3
A and B
A= defined $valB= length $val
ABresult
0X0
100
111
4268 length( $val ) )
4269 {
4270 1 ▶ if( defined( $re ) &&
Branch: 3 branches
BranchTrueFalseTotal
if (defined $re and not $val =~ /^$re$/) { } 0 1 1
elsif (defined $type and $type eq 'boolean') { } 0 1 1
elsif (defined $isa) { } 0 1 1
Condition33%1/3
defined $re and not $val =~ /^$re$/
!ll&&!rl&&r
100
MC/DC0%0/2
defined $re and not $val =~ /^$re$/
defined $re not $val =~ /^$re$/
Truth table33%1/3
A and not(B)
A= defined $reB= not $val =~ /^$re$/
ABresult
0X0
100
111
4271 $val !~ /^$re$/ )
4272 {
4273 0 return( $self->error( "Invalid value provided for \"${field}\": ${val}" ) );
4274 }
4275 ▶ elsif( defined( $type ) &&
Condition33%1/3
defined $type and $type eq "boolean"
!ll&&!rl&&r
100
MC/DC0%0/2
defined $type and $type eq "boolean"
defined $type $type eq "boolean"
Truth table33%1/3
A and B
A= defined $typeB= $type eq "boolean"
ABresult
0X0
100
111
4276 $type eq 'boolean' )
4277 {
4278 0 $val = lc( $val );
4279 0 ▶ if( $val =~ /^(?:yes|no)$/i )
Branch: 3 branches
BranchTrueFalseTotal
if ($val =~ /^(?:yes|no)$/i) { } 0 0 0
elsif ($val =~ /^(?:true|false)$/i) { } 0 0 0
elsif ($val =~ /^(?:1|0)$/) { } 0 0 0
4280 {
4281 0 $self->{_bool_types}->{ $field } = 'literal';
4282 0 ▶ $val = ( $val eq 'yes' ? $self->true : $self->false );
Branch: 1 branch
BranchTrueFalseTotal
$val eq 'yes' ? : 0 0 0
4283 }
4284 elsif( $val =~ /^(?:true|false)$/i )
4285 {
4286 0 $self->{_bool_types}->{ $field } = 'logic';
4287 0 ▶ $val = ( $val eq 'true' ? $self->true : $self->false );
Branch: 1 branch
BranchTrueFalseTotal
$val eq 'true' ? : 0 0 0
4288 }
4289 elsif( $val =~ /^(?:1|0)$/ )
4290 {
4291 0 $self->{_bool_types}->{ $field } = 'logic';
4292 0 ▶ $val = ( $val ? $self->true : $self->false );
Branch: 1 branch
BranchTrueFalseTotal
$val ? : 0 0 0
4293 }
4294 else
4295 {
4296 0 ▶ warn( "Unexpected value used as boolean for attribute \"${field}\": ${val}" ) if( warnings::enabled() );
Branch: 1 branch
BranchTrueFalseTotal
if warnings::enabled() 0 0 0
4297 0 ▶ $val = ( $val ? $self->true : $self->false );
Branch: 1 branch
BranchTrueFalseTotal
$val ? : 0 0 0
4298 }
4299 }
4300 elsif( defined( $isa ) )
4301 {
4302 0 ▶ if( !Scalar::Util::blessed( $val ) ||
Branch: 1 branch
BranchTrueFalseTotal
if (not builtin::blessed($val) or builtin::blessed($val) and not $val->isa($isa)) 0 0 0
Condition0%0/6
not builtin::blessed($val) or builtin::blessed($val) and not $val->isa($isa)
l!l&&r!l&&!r
000
builtin::blessed($val) and not $val->isa($isa)
!ll&&!rl&&r
000
MC/DC0%0/3
not builtin::blessed($val) or builtin::blessed($val) and not $val->isa($isa)
not builtin::blessed($val) builtin::blessed($val) not $val->isa($isa)
Truth table0%0/4
not(A) or B and not(C)
A= not builtin::blessed($val)B= builtin::blessed($val)C= not $val->isa($isa)
ABCresult
1XX1
0111
00X0
0100
4303 ( Scalar::Util::blessed( $val ) && !$val->isa( $isa ) ) )
4304 {
4305 0 return( $self->error( "Value provided is not an ${isa} object." ) );
4306 }
4307 }
4308 }
4309 1 $self->{ $field } = $val
4310 }
4311 # So chaining works
4312 1431 ▶ rreturn( $self ) if( want( 'OBJECT' ) );
Branch: 1 branch
BranchTrueFalseTotal
if want("OBJECT") 0 1431 1431
4313 # Returns undef in scalar context and an empty list in list context
4314 1431 ▶ return if( !defined( $self->{ $field } ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{$field} 0 1431 1431
4315 1431 return( $self->{ $field } );
4316 }
4317  
4318 sub _get_args_as_hash
4319 1218 ▶{
Subroutine _get_args_as_hash: called CC=6 SCAR=24.2
4320 1218 my $self = shift( @_ );
4321 1218 my $ref = {};
4322 1218 ▶ if( scalar( @_ ) == 1 &&
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @_ == 1 and defined $_[0] and (ref $_[0] || '') eq 'HASH') { } 0 1218 1218
elsif (not scalar(@_) % 2) { } 1218 0 1218
Condition25%2/8
scalar @_ == 1 and defined $_[0] and (ref $_[0] || "") eq "HASH"
!ll&&!rl&&r
121800
scalar @_ == 1 and defined $_[0]
!ll&&!rl&&r
121800
ref $_[0] || ''
l!l
00
MC/DC0%0/3
scalar @_ == 1 and defined $_[0] and (ref $_[0] || "") eq "HASH"
scalar @_ == 1 defined $_[0] ref $_[0]
Truth table25%1/4
A and B and C
A= scalar @_ == 1B= defined $_[0]C= ref $_[0]
ABCresult
0XX0
10X0
1100
1111
4323 defined( $_[0] ) &&
4324 ( ref( $_[0] ) || '' ) eq 'HASH' )
4325 {
4326 0 $ref = shift( @_ );
4327 }
4328 elsif( !( scalar( @_ ) % 2 ) )
4329 {
4330 1218 $ref = { @_ };
4331 }
4332 else
4333 {
4334 0 die( "Uneven number of parameters provided." );
4335 }
4336 1218 return( $ref );
4337 }
4338  
4339 # NOTE: CLONE
4340 sub CLONE
4341 0 ▶{
Subroutine CLONE: not called CC=1 SCAR=6.9
4342 # Discard database and statement handles inherited from the parent thread.
4343 # Each child thread will establish its own SQLite connections as needed.
4344 0 $IS_CHILD_THREAD = 1;
4345 0 $STHS = {};
4346 0 $DBH = {};
4347 }
4348  
4349  
4350 # NOTE: END
4351 END
4352 7 ▶{
Subroutine END: called CC=19 SCAR=35.0
4353 # On systems with a strict memory allocator, such as OpenBSD, a cached statement
4354 # handle must be finalised while its parent database handle is still alive. During
4355 # Perl global destruction the order in which the package globals and the cached
4356 # handles are reclaimed is not guaranteed, so a statement handle may be finalised
4357 # after its SQLite connection has already been closed. That is a use-after-free,
4358 # and OpenBSD aborts the process with a SIGSEGV. We therefore tear everything down
4359 # here, in a deterministic order, before global destruction begins: the statement
4360 # handles first, then the database handles.
4361 #
4362 # Child threads must not explicitly finalise or disconnect DBI handles.
4363 # Their inherited caches are discarded by CLONE, and DBI handles their normal
4364 # destruction. The main interpreter retains ordered cleanup.
4365 7 ▶ unless( $IS_CHILD_THREAD )
Branch: 1 branch
BranchTrueFalseTotal
unless ($Locale::Unicode::Data::IS_CHILD_THREAD) 7 0 7
4366 {
4367 7 ▶ if( defined( $STHS ) && ref( $STHS ) eq 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Locale::Unicode::Data::STHS and ref $Locale::Unicode::Data::STHS eq "HASH") 7 0 7
Condition33%1/3
defined $Locale::Unicode::Data::STHS and ref $Locale::Unicode::Data::STHS eq "HASH"
!ll&&!rl&&r
007
MC/DC0%0/2
defined $Locale::Unicode::Data::STHS and ref $Locale::Unicode::Data::STHS eq "HASH"
defined $Locale::Unicode::Data::STHS ref $Locale::Unicode::Data::STHS eq "HASH"
Truth table33%1/3
A and B
A= defined $Locale::Unicode::Data::STHSB= ref $Locale::Unicode::Data::STHS eq "HASH"
ABresult
0X0
100
111
4368 {
4369 7 foreach my $tid ( keys( %$STHS ) )
4370 {
4371 5 ▶ next unless( ref( $STHS->{ $tid } ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $Locale::Unicode::Data::STHS->{$tid} eq "HASH" 0 5 5
4372 5 foreach my $db ( keys( %{$STHS->{ $tid }} ) )
4373 {
4374 5 ▶ next unless( ref( $STHS->{ $tid }->{ $db } ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $Locale::Unicode::Data::STHS->{$tid}{$db} eq "HASH" 0 5 5
4375 5 foreach my $id ( keys( %{$STHS->{ $tid }->{ $db }} ) )
4376 {
4377 208 my $sth = delete( $STHS->{ $tid }->{ $db }->{ $id } );
4378 208 ▶ if( defined( $sth ) && Scalar::Util::blessed( $sth ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sth and builtin::blessed($sth)) 208 0 208
Condition33%1/3
defined $sth and builtin::blessed($sth)
!ll&&!rl&&r
00208
MC/DC0%0/2
defined $sth and builtin::blessed($sth)
defined $sth builtin::blessed($sth)
Truth table33%1/3
A and B
A= defined $sthB= builtin::blessed($sth)
ABresult
0X0
100
111
4379 {
4380 208 $sth->finish;
4381 }
4382 # Drop our reference now so the handle is finalised while its
4383 # database handle is still open.
4384 208 undef( $sth );
4385 }
4386 }
4387 }
4388 }
4389  
4390 7 ▶ if( defined( $DBH ) && ref( $DBH ) eq 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH") 7 0 7
Condition33%1/3
defined $Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH"
!ll&&!rl&&r
007
MC/DC0%0/2
defined $Locale::Unicode::Data::DBH and ref $Locale::Unicode::Data::DBH eq "HASH"
defined $Locale::Unicode::Data::DBH ref $Locale::Unicode::Data::DBH eq "HASH"
Truth table33%1/3
A and B
A= defined $Locale::Unicode::Data::DBHB= ref $Locale::Unicode::Data::DBH eq "HASH"
ABresult
0X0
100
111
4391 {
4392 7 foreach my $tid ( keys( %$DBH ) )
4393 {
4394 6 ▶ next unless( ref( $DBH->{ $tid } ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $Locale::Unicode::Data::DBH->{$tid} eq "HASH" 0 6 6
4395 6 foreach my $db ( keys( %{$DBH->{ $tid }} ) )
4396 {
4397 6 my $dbh = delete( $DBH->{ $tid }->{ $db } );
4398 6 ▶ if( defined( $dbh ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dbh and builtin::blessed($dbh) and $dbh->isa("DBI::db")) 6 0 6
Condition33%2/6
defined $dbh and builtin::blessed($dbh) and $dbh->isa("DBI::db")
!ll&&!rl&&r
006
defined $dbh and builtin::blessed($dbh)
!ll&&!rl&&r
006
MC/DC0%0/3
defined $dbh and builtin::blessed($dbh) and $dbh->isa("DBI::db")
defined $dbh builtin::blessed($dbh) $dbh->isa("DBI::db")
Truth table25%1/4
A and B and C
A= defined $dbhB= builtin::blessed($dbh)C= $dbh->isa("DBI::db")
ABCresult
0XX0
10X0
1100
1111
4399 Scalar::Util::blessed( $dbh ) &&
4400 $dbh->isa( 'DBI::db' ) )
4401 {
4402 6 $dbh->disconnect;
4403 }
4404 6 undef( $dbh );
4405 }
4406 }
4407 }
4408 }
4409 };
4410  
4411 sub FREEZE
4412 0 ▶{
Subroutine FREEZE: not called CC=4 SCAR=30.0
Pod undocumented
4413 0 my $self = CORE::shift( @_ );
4414 0 ▶ my $serialiser = CORE::shift( @_ ) // '';
Condition0%0/2
shift @_ // ""
l!l
00
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
4415 0 my $class = CORE::ref( $self );
4416 0 my @keys = qw( datafile decode_sql_arrays fatal );
4417 0 my %hash = ();
4418 0 @hash{ @keys } = @$self{ @keys };
4419 # Return an array reference rather than a list so this works with Sereal and CBOR
4420 # On or before Sereal version 4.023, Sereal did not support multiple values returned
4421 0 ▶ CORE::return( [$class, %hash] ) if( $serialiser eq 'Sereal' && Sereal::Encoder->VERSION <= version->parse( '4.023' ) );
Branch: 1 branch
BranchTrueFalseTotal
if $serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023") 0 0 0
Condition0%0/3
$serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
!ll&&!rl&&r
000
MC/DC0%0/2
$serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
$serialiser eq "Sereal" "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
Truth table0%0/3
A and B
A= $serialiser eq "Sereal"B= "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
ABresult
0X0
100
111
4422 # But Storable want a list with the first element being the serialised element
4423 0 CORE::return( $class, \%hash );
4424 }
4425  
4426 0 ▶sub STORABLE_freeze { return( shift->FREEZE( @_ ) ); }
Subroutine STORABLE_freeze: not called CC=1 SCAR=6.9
Pod undocumented
4427  
4428 0 ▶sub STORABLE_thaw { return( shift->THAW( @_ ) ); }
Subroutine STORABLE_thaw: not called CC=1 SCAR=6.9
Pod undocumented
4429  
4430 # NOTE: CBOR will call the THAW method with the stored classname as first argument, the constant string CBOR as second argument, and all values returned by FREEZE as remaining arguments.
4431 # NOTE: Storable calls it with a blessed object it created followed with $cloning and any other arguments initially provided by STORABLE_freeze
4432 sub THAW
4433 0 ▶{
Subroutine THAW: not called CC=10 SCAR=47.0
Pod undocumented
4434 0 my( $self, undef, @args ) = @_;
4435 0 ▶ my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args;
Branch: 1 branch
BranchTrueFalseTotal
scalar @args == 1 && ref $args[0] eq 'ARRAY' ? : 0 0 0
Condition0%0/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1 ref $args[0] eq "ARRAY"
Truth table0%0/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
ABresult
0X0
100
111
4436 0 ▶ my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self );
Branch: 1 branch
BranchTrueFalseTotal
defined $ref && ref $ref eq 'ARRAY' && scalar @$ref > 1 ? : 0 0 0
Condition0%0/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
!ll&&!rl&&r
000
defined $ref and ref $ref eq "ARRAY"
!ll&&!rl&&r
000
ref $self or $self
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref ref $ref eq "ARRAY" scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self $self
Truth table0%0/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/3
A or B
A= ref $selfB= $self
ABresult
1X1
011
000
4437 0 ▶ my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $ref eq 'ARRAY' ? : 0 0 0
4438 0 my $new;
4439 # Storable pattern requires to modify the object it created rather than returning a new one
4440 0 ▶ if( CORE::ref( $self ) )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
4441 {
4442 0 foreach( CORE::keys( %$hash ) )
4443 {
4444 0 $self->{ $_ } = CORE::delete( $hash->{ $_ } );
4445 }
4446 0 $new = $self;
4447 }
4448 else
4449 {
4450 0 $new = CORE::bless( $hash => $class );
4451 }
4452 0 CORE::return( $new );
4453 }
4454  
4455 sub TO_JSON
4456 0 ▶{
Subroutine TO_JSON: not called CC=1 SCAR=6.9
Pod undocumented
4457 0 my $self = CORE::shift( @_ );
4458 0 my @keys = qw( datafile decode_sql_arrays );
4459 0 my $hash = {};
4460 0 @$hash{ @keys } = @$self{ @keys };
4461 0 return( $hash );
4462 }
4463  
4464 # NOTE: Locale::Unicode::Data::Boolean class
4465 package Locale::Unicode::Data::Boolean;
4466 BEGIN
4467 7 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.2
4468 7 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4469 7 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4470 7 ▶ use vars qw( $VERSION $true $false );
Subroutine BEGIN: called CC=1 SCAR=0.0
4471 use overload
4472 0 ▶ "0+" => sub{ ${$_[0]} },
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=6.9
4473 0 ▶ "++" => sub{ $_[0] = ${$_[0]} + 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
4474 0 ▶ "--" => sub{ $_[0] = ${$_[0]} - 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
4475 7 fallback => 1;
4476 7 $true = do{ bless( \( my $dummy = 1 ) => 'Locale::Unicode::Data::Boolean' ) };
4477 7 $false = do{ bless( \( my $dummy = 0 ) => 'Locale::Unicode::Data::Boolean' ) };
4478 7 our $VERSION = 'v0.1.0';
4479 };
4480 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4481 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4482  
4483 sub new
4484 0 ▶{
Subroutine new: not called CC=3 SCAR=24.8
4485 0 my $this = shift( @_ );
4486 0 ▶ my $self = bless( \( my $dummy = ( $_[0] ? 1 : 0 ) ) => ( ref( $this ) || $this ) );
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 0 0 0
Condition0%0/3
ref $this || $this
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table0%0/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
4487 }
4488  
4489 sub clone
4490 0 ▶{
Subroutine clone: not called CC=2 SCAR=17.9
4491 0 my $self = shift( @_ );
4492 0 ▶ unless( ref( $self ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 0 0 0
4493 {
4494 0 die( "clone() must be called with an object." );
4495 }
4496 0 my $copy = $$self;
4497 0 my $new = bless( \$copy => ref( $self ) );
4498 0 return( $new );
4499 }
4500  
4501 0 ▶sub false() { $false }
Subroutine false: not called CC=1 SCAR=6.9
4502  
4503 0 ▶sub is_bool($) { UNIVERSAL::isa( $_[0], 'Locale::Unicode::Data::Boolean' ) }
Subroutine is_bool: not called CC=1 SCAR=6.9
4504  
4505 0 ▶sub is_true($) { $_[0] && UNIVERSAL::isa( $_[0], 'Locale::Unicode::Data::Boolean' ) }
Subroutine is_true: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] and UNIVERSAL::isa($_[0], "Locale::Unicode::Data::Boolean") 0 0 0
4506  
4507 0 ▶sub is_false($) { !$_[0] && UNIVERSAL::isa( $_[0], 'Locale::Unicode::Data::Boolean' ) }
Subroutine is_false: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
not $_[0] and UNIVERSAL::isa($_[0], "Locale::Unicode::Data::Boolean") 0 0 0
4508  
4509 0 ▶sub true() { $true }
Subroutine true: not called CC=1 SCAR=6.9
4510  
4511 sub FREEZE
4512 0 ▶{
Subroutine FREEZE: not called CC=4 SCAR=30.0
4513 0 my $self = CORE::shift( @_ );
4514 0 ▶ my $serialiser = CORE::shift( @_ ) // '';
Condition0%0/2
shift @_ // ""
l!l
00
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
4515 0 my $class = CORE::ref( $self );
4516 # Return an array reference rather than a list so this works with Sereal and CBOR
4517 # On or before Sereal version 4.023, Sereal did not support multiple values returned
4518 0 ▶ CORE::return( [$class, $$self] ) if( $serialiser eq 'Sereal' && Sereal::Encoder->VERSION <= version->parse( '4.023' ) );
Branch: 1 branch
BranchTrueFalseTotal
if $serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023") 0 0 0
Condition0%0/3
$serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
!ll&&!rl&&r
000
MC/DC0%0/2
$serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
$serialiser eq "Sereal" "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
Truth table0%0/3
A and B
A= $serialiser eq "Sereal"B= "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
ABresult
0X0
100
111
4519 # But Storable want a list with the first element being the serialised element
4520 0 CORE::return( $$self );
4521 }
4522  
4523 0 ▶sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); }
Subroutine STORABLE_freeze: not called CC=1 SCAR=6.9
4524  
4525 0 ▶sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); }
Subroutine STORABLE_thaw: not called CC=1 SCAR=6.9
4526  
4527 # NOTE: CBOR will call the THAW method with the stored classname as first argument, the constant string CBOR as second argument, and all values returned by FREEZE as remaining arguments.
4528 # NOTE: Storable calls it with a blessed object it created followed with $cloning and any other arguments initially provided by STORABLE_freeze
4529 sub THAW
4530 0 ▶{
Subroutine THAW: not called CC=5 SCAR=34.0
4531 0 my( $self, undef, @args ) = @_;
4532 0 my( $class, $str );
4533 0 ▶ if( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 1 and ref $args[0] eq 'ARRAY') { } 0 0 0
Condition0%0/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1 ref $args[0] eq "ARRAY"
Truth table0%0/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
ABresult
0X0
100
111
4534 {
4535 0 ( $class, $str ) = @{$args[0]};
4536 }
4537 else
4538 {
4539 0 ▶ $class = CORE::ref( $self ) || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
4540 0 $str = CORE::shift( @args );
4541 }
4542 # Storable pattern requires to modify the object it created rather than returning a new one
4543 0 ▶ if( CORE::ref( $self ) )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
4544 {
4545 0 $$self = $str;
4546 0 CORE::return( $self );
4547 }
4548 else
4549 {
4550 0 CORE::return( $class->new( $str ) );
4551 }
4552 }
4553  
4554 sub TO_JSON
4555 0 ▶{
Subroutine TO_JSON: not called CC=2 SCAR=17.9
4556 # JSON does not check that the value is a proper true or false. It stupidly assumes this is a string
4557 # The only way to make it understand is to return a scalar ref of 1 or 0
4558 # return( $_[0] ? 'true' : 'false' );
4559 0 ▶ return( $_[0] ? \1 : \0 );
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 0 0 0
4560 }
4561  
4562 # NOTE: Locale::Unicode::Data::Exception class
4563 package Locale::Unicode::Data::Exception;
4564 BEGIN
4565 7 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
4566 7 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4567 7 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4568 7 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
4569 7 ▶ use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
4570 '""' => 'as_string',
4571 1 ▶ bool => sub{ $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
4572 7 fallback => 1,
4573 7 );
4574 7 our $VERSION = 'v0.1.0';
4575 };
4576 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4577 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4578 7 ▶use overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
4579  
4580 sub new
4581 3 ▶{
Subroutine new: called CC=12 SCAR=33.2
4582 3 my $this = shift( @_ );
4583 3 ▶ my $self = bless( {} => ( ref( $this ) || $this ) );
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
4584 3 my @info = caller;
4585 3 @$self{ qw( package file line ) } = @info[0..2];
4586 3 my $args = {};
4587 3 ▶ if( scalar( @_ ) == 1 )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ == 1) { } 3 0 3
4588 {
4589 3 ▶ if( ( ref( $_[0] ) || '' ) eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if ((ref $_[0] || '') eq 'HASH') { } 3 0 3
elsif (ref $_[0] and $_[0]->isa('Locale::Unicode::Data::Exception')) { } 0 0 0
Condition50%1/2
ref $_[0] || ''
l!l
30
MC/DC0%0/1
ref $_[0] || ''
ref $_[0]
Truth table50%1/2
A
A= ref $_[0]
Aresult
11
00
4590 {
4591 3 $args = shift( @_ );
4592 3 ▶ if( $args->{skip_frames} )
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"skip_frames"}) 3 0 3
4593 {
4594 3 @info = caller( int( $args->{skip_frames} ) );
4595 3 @$self{ qw( package file line ) } = @info[0..2];
4596 }
4597 3 ▶ $args->{message} ||= '';
Condition50%1/2
$args->{"message"} ||= ""
l!l
30
MC/DC0%0/1
$args->{"message"} ||= ""
$args->{"message"}
Truth table50%1/2
A
A= $args->{"message"}
Aresult
11
00
4598 3 foreach my $k ( qw( package file line message code type retry_after ) )
4599 {
4600 21 ▶ $self->{ $k } = $args->{ $k } if( CORE::exists( $args->{ $k } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{$k} 3 18 21
4601 }
4602 }
4603 ▶ elsif( ref( $_[0] ) && $_[0]->isa( 'Locale::Unicode::Data::Exception' ) )
Condition0%0/3
ref $_[0] and $_[0]->isa("Locale::Unicode::Data::Exception")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[0] and $_[0]->isa("Locale::Unicode::Data::Exception")
ref $_[0] $_[0]->isa("Locale::Unicode::Data::Exception")
Truth table0%0/3
A and B
A= ref $_[0]B= $_[0]->isa("Locale::Unicode::Data::Exception")
ABresult
0X0
100
111
4604 {
4605 0 my $o = $args->{object} = shift( @_ );
4606 0 $self->{message} = $o->message;
4607 0 $self->{code} = $o->code;
4608 0 $self->{type} = $o->type;
4609 0 $self->{retry_after} = $o->retry_after;
4610 }
4611 else
4612 {
4613 0 die( "Unknown argument provided: '", overload::StrVal( $_[0] ), "'" );
4614 }
4615 }
4616 else
4617 {
4618 0 ▶ $self->{message} = join( '', map( ref( $_ ) eq 'CODE' ? $_->() : $_, @_ ) );
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'CODE' ? : 0 0 0
4619 }
4620 3 return( $self );
4621 }
4622  
4623 # This is important as stringification is called by die, so as per the manual page, we need to end with new line
4624 # And will add the stack trace
4625 sub as_string
4626 0 ▶{
Subroutine as_string: not called CC=6 SCAR=33.9
4627 7 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
4628 0 my $self = shift( @_ );
4629 0 ▶ return( $self->{_cache_value} ) if( $self->{_cache_value} && !CORE::length( $self->{_reset} ) );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_cache_value"} and not length $self->{"_reset"} 0 0 0
Condition0%0/3
$self->{"_cache_value"} and not length $self->{"_reset"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"_cache_value"} and not length $self->{"_reset"}
$self->{"_cache_value"} not length $self->{"_reset"}
Truth table0%0/3
A and not(B)
A= $self->{"_cache_value"}B= not length $self->{"_reset"}
ABresult
0X0
100
111
4630 0 my $str = $self->message;
4631 0 $str = "$str";
4632 0 $str =~ s/\r?\n$//g;
4633 0 ▶ $str .= sprintf( " within package %s at line %d in file %s", ( $self->{package} // 'undef' ), ( $self->{line} // 'undef' ), ( $self->{file} // 'undef' ) );
Condition0%0/6
$self->{"package"} // "undef"
l!l
00
$self->{"line"} // "undef"
l!l
00
$self->{"file"} // "undef"
l!l
00
MC/DC0%0/1
$self->{"package"} // "undef"
$self->{"package"}
MC/DC0%0/1
$self->{"line"} // "undef"
$self->{"line"}
MC/DC0%0/1
$self->{"file"} // "undef"
$self->{"file"}
Truth table0%0/2
A
A= $self->{"package"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"line"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"file"}
Aresult
11
00
4634 0 $self->{_cache_value} = $str;
4635 0 CORE::delete( $self->{_reset} );
4636 0 return( $str );
4637 }
4638  
4639 sub clone
4640 0 ▶{
Subroutine clone: not called CC=2 SCAR=17.9
4641 0 my $self = shift( @_ );
4642 # Safeguard
4643 0 ▶ die( "$self->clone() cannot be called as a class function" ) unless( ref( $self ) );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
4644 0 my $new = bless( { %$self } => ref( $self ) );
4645 0 CORE::delete( $new->{_cache_value} );
4646 0 return( $new );
4647 }
4648  
4649 0 ▶sub code { return( shift->reset(@_)->_set_get_prop( 'code', @_ ) ); }
Subroutine code: not called CC=1 SCAR=6.9
4650  
4651 0 ▶sub file { return( shift->reset(@_)->_set_get_prop( 'file', @_ ) ); }
Subroutine file: not called CC=1 SCAR=6.9
4652  
4653 0 ▶sub line { return( shift->reset(@_)->_set_get_prop( 'line', @_ ) ); }
Subroutine line: not called CC=1 SCAR=6.9
4654  
4655 2 ▶sub message { return( shift->reset(@_)->_set_get_prop( 'message', @_ ) ); }
Subroutine message: called CC=1 SCAR=0.0
4656  
4657 0 ▶sub package { return( shift->reset(@_)->_set_get_prop( 'package', @_ ) ); }
Subroutine package: not called CC=1 SCAR=6.9
4658  
4659 # From perlfunc docmentation on "die":
4660 # "If LIST was empty or made an empty string, and $@ contains an
4661 # object reference that has a "PROPAGATE" method, that method will
4662 # be called with additional file and line number parameters. The
4663 # return value replaces the value in $@; i.e., as if "$@ = eval {
4664 # $@->PROPAGATE(__FILE__, __LINE__) };" were called."
4665 sub PROPAGATE
4666 0 ▶{
Subroutine PROPAGATE: not called CC=3 SCAR=24.8
4667 0 my( $self, $file, $line ) = @_;
4668 0 ▶ if( defined( $file ) && defined( $line ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file and defined $line) 0 0 0
Condition0%0/3
defined $file and defined $line
!ll&&!rl&&r
000
MC/DC0%0/2
defined $file and defined $line
defined $file defined $line
Truth table0%0/3
A and B
A= defined $fileB= defined $line
ABresult
0X0
100
111
4669 {
4670 0 my $clone = $self->clone;
4671 0 $clone->file( $file );
4672 0 $clone->line( $line );
4673 0 return( $clone );
4674 }
4675 0 return( $self );
4676 }
4677  
4678 sub reset
4679 2 ▶{
Subroutine reset: called CC=3 SCAR=12.5
4680 2 my $self = shift( @_ );
4681 2 ▶ if( !CORE::length( $self->{_reset} ) && scalar( @_ ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not length $self->{"_reset"} and scalar @_) 0 2 2
Condition50%1/2
not length $self->{"_reset"} and scalar @_
!ll
02
MC/DC0%0/1
not length $self->{"_reset"} and scalar @_
not length $self->{"_reset"}
Truth table50%1/2
not(A)
A= not length $self->{"_reset"}
Aresult
00
11
4682 {
4683 0 $self->{_reset} = scalar( @_ );
4684 }
4685 2 return( $self );
4686 }
4687  
4688 sub rethrow
4689 0 ▶{
Subroutine rethrow: not called CC=2 SCAR=17.9
4690 0 my $self = shift( @_ );
4691 0 ▶ return if( !ref( $self ) );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
4692 0 die( $self );
4693 }
4694  
4695 0 ▶sub retry_after { return( shift->_set_get_prop( 'retry_after', @_ ) ); }
Subroutine retry_after: not called CC=1 SCAR=6.9
4696  
4697 sub throw
4698 0 ▶{
Subroutine throw: not called CC=2 SCAR=17.9
4699 0 my $self = shift( @_ );
4700 0 my $e;
4701 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
4702 {
4703 0 my $msg = shift( @_ );
4704 0 $e = $self->new({
4705 skip_frames => 1,
4706 message => $msg,
4707 });
4708 }
4709 else
4710 {
4711 0 $e = $self;
4712 }
4713 0 die( $e );
4714 }
4715  
4716 0 ▶sub type { return( shift->reset(@_)->_set_get_prop( 'type', @_ ) ); }
Subroutine type: not called CC=1 SCAR=6.9
4717  
4718 sub _set_get_prop
4719 2 ▶{
Subroutine _set_get_prop: called CC=3 SCAR=11.4
4720 2 my $self = shift( @_ );
4721 2 ▶ my $prop = shift( @_ ) || die( "No object property was provided." );
Condition50%1/2
shift @_ || die('No object property was provided.')
l!l
20
MC/DC0%0/1
shift @_ || die('No object property was provided.')
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
4722 2 ▶ $self->{ $prop } = shift( @_ ) if( @_ );
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 2 2
4723 2 return( $self->{ $prop } );
4724 }
4725  
4726 sub FREEZE
4727 0 ▶{
Subroutine FREEZE: not called CC=4 SCAR=30.0
4728 0 my $self = CORE::shift( @_ );
4729 0 ▶ my $serialiser = CORE::shift( @_ ) // '';
Condition0%0/2
shift @_ // ""
l!l
00
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
4730 0 my $class = CORE::ref( $self );
4731 0 my %hash = %$self;
4732 # Return an array reference rather than a list so this works with Sereal and CBOR
4733 # On or before Sereal version 4.023, Sereal did not support multiple values returned
4734 0 ▶ CORE::return( [$class, \%hash] ) if( $serialiser eq 'Sereal' && Sereal::Encoder->VERSION <= version->parse( '4.023' ) );
Branch: 1 branch
BranchTrueFalseTotal
if $serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023") 0 0 0
Condition0%0/3
$serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
!ll&&!rl&&r
000
MC/DC0%0/2
$serialiser eq "Sereal" and "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
$serialiser eq "Sereal" "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
Truth table0%0/3
A and B
A= $serialiser eq "Sereal"B= "Sereal::Encoder"->VERSION <= "version"->parse("4.023")
ABresult
0X0
100
111
4735 # But Storable want a list with the first element being the serialised element
4736 0 CORE::return( $class, \%hash );
4737 }
4738  
4739 0 ▶sub STORABLE_freeze { return( shift->FREEZE( @_ ) ); }
Subroutine STORABLE_freeze: not called CC=1 SCAR=6.9
4740  
4741 0 ▶sub STORABLE_thaw { return( shift->THAW( @_ ) ); }
Subroutine STORABLE_thaw: not called CC=1 SCAR=6.9
4742  
4743 # NOTE: CBOR will call the THAW method with the stored classname as first argument, the constant string CBOR as second argument, and all values returned by FREEZE as remaining arguments.
4744 # NOTE: Storable calls it with a blessed object it created followed with $cloning and any other arguments initially provided by STORABLE_freeze
4745 sub THAW
4746 0 ▶{
Subroutine THAW: not called CC=10 SCAR=47.0
4747 0 my( $self, undef, @args ) = @_;
4748 0 ▶ my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args;
Branch: 1 branch
BranchTrueFalseTotal
scalar @args == 1 && ref $args[0] eq 'ARRAY' ? : 0 0 0
Condition0%0/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1 ref $args[0] eq "ARRAY"
Truth table0%0/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
ABresult
0X0
100
111
4749 0 ▶ my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self );
Branch: 1 branch
BranchTrueFalseTotal
defined $ref && ref $ref eq 'ARRAY' && scalar @$ref > 1 ? : 0 0 0
Condition0%0/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
!ll&&!rl&&r
000
defined $ref and ref $ref eq "ARRAY"
!ll&&!rl&&r
000
ref $self or $self
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref ref $ref eq "ARRAY" scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self $self
Truth table0%0/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/3
A or B
A= ref $selfB= $self
ABresult
1X1
011
000
4750 0 ▶ my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $ref eq 'ARRAY' ? : 0 0 0
4751 0 my $new;
4752 # Storable pattern requires to modify the object it created rather than returning a new one
4753 0 ▶ if( CORE::ref( $self ) )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
4754 {
4755 0 foreach( CORE::keys( %$hash ) )
4756 {
4757 0 $self->{ $_ } = CORE::delete( $hash->{ $_ } );
4758 }
4759 0 $new = $self;
4760 }
4761 else
4762 {
4763 0 $new = CORE::bless( $hash => $class );
4764 }
4765 0 CORE::return( $new );
4766 }
4767  
4768 0 ▶sub TO_JSON { return( shift->as_string ); }
Subroutine TO_JSON: not called CC=1 SCAR=6.9
4769  
4770 {
4771 # NOTE: Locale::Unicode::Data::NullObject class
4772 package
4773 Locale::Unicode::Data::NullObject;
4774 BEGIN
4775 {
4776 7 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4777 7 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4778 7 ▶ use overload (
Subroutine BEGIN: called CC=1 SCAR=0.2
4779 0 ▶ '""' => sub{ '' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
4780 7 fallback => 1,
4781 7 );
4782 7 ▶ use Wanted;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: not called CC=1 SCAR=0.0
4783 };
4784 7 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4785 7 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4786  
4787 sub new
4788 0 ▶ {
Subroutine new: not called CC=3 SCAR=24.8
4789 0 my $this = shift( @_ );
4790 0 ▶ my $ref = @_ ? { @_ } : {};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
4791 0 ▶ return( bless( $ref => ( ref( $this ) || $this ) ) );
Condition0%0/3
ref $this || $this
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table0%0/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
4792 }
4793  
4794 sub AUTOLOAD
4795 0 ▶ {
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
4796 0 my( $method ) = our $AUTOLOAD =~ /([^:]+)$/;
4797 0 my $self = shift( @_ );
4798 0 ▶ if( want( 'OBJECT' ) )
Branch: 1 branch
BranchTrueFalseTotal
if (want("OBJECT")) 0 0 0
4799 {
4800 0 rreturn( $self );
4801 }
4802 # Otherwise, we return undef; Empty return returns undef in scalar context and empty list in list context
4803 0 return;
4804 };
4805 }
4806  
4807 7 1;
4808 # NOTE: POD
4809 __END__
↑ Summary