Coerce/perl/To_timeofday/From_obj/date_timeofday.pm

filter: Statementstmt 92.3% 24 / 26 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 75.5% 34 / 45 CC 6 SCAR 15.5
CC
6
Cov
81%
coerce
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 4.7
« Coerce/perl/To_date/From_obj/time_moment.pm ↑ Summary Coerce/perl/To_duration/From_str/human.pm »
1 package Data::Sah::Coerce::perl::To_timeofday::From_obj::date_timeofday;
2  
3 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8 2 our $DATE = '2023-10-24'; # DATE
9 2 our $DIST = 'Data-Sah-Coerce'; # DIST
10 2 our $VERSION = '0.054'; # VERSION
11  
12 2 ▶sub meta {
Subroutine meta: called CC=1 SCAR=0.0
Pod undocumented
13 +{
14 2 v => 4,
15 summary => 'Coerce timeofday from Date::TimeOfDay object',
16 prio => 50,
17 };
18 }
19  
20 2 ▶sub coerce {
Subroutine coerce: called CC=6 SCAR=19.7
Pod undocumented
21 2 my %args = @_;
22  
23 2 my $dt = $args{data_term};
24 2 ▶ my $coerce_to = $args{coerce_to} // 'str_hms';
Condition50%1/2
$args{"coerce_to"} // "str_hms"
l!l
20
MC/DC0%0/1
$args{"coerce_to"} // "str_hms"
$args{"coerce_to"}
Truth table50%1/2
A
A= $args{"coerce_to"}
Aresult
11
00
25  
26 2 my $res = {};
27  
28 2 ▶ $res->{modules}{'Scalar::Util'} //= 0;
Condition50%1/2
$res->{"modules"}{"Scalar::Util"} //= 0
l!l
02
MC/DC0%0/1
$res->{"modules"}{"Scalar::Util"} //= 0
$res->{"modules"}{"Scalar::Util"}
Truth table50%1/2
A
A= $res->{"modules"}{"Scalar::Util"}
Aresult
11
00
29  
30 2 $res->{expr_match} = join(
31 " && ",
32 "Scalar::Util::blessed($dt)",
33 "$dt\->isa('Date::TimeOfDay')",
34 );
35  
36 2 ▶ if ($coerce_to eq 'float') {
Branch: 3 branches
BranchTrueFalseTotal
if ($coerce_to eq 'float') { } 1 1 2
elsif ($coerce_to eq 'str_hms') { } 1 0 1
elsif ($coerce_to eq 'Date::TimeOfDay') { } 0 0 0
37 1 $res->{expr_coerce} = "$dt\->float";
38 } elsif ($coerce_to eq 'str_hms') {
39 1 $res->{expr_coerce} = "$dt\->hms";
40 } elsif ($coerce_to eq 'Date::TimeOfDay') {
41 0 $res->{expr_coerce} = $dt;
42 } else {
43 0 die "BUG: Unknown coerce_to value '$coerce_to', ".
44 "please use float, str_hms, or Date::TimeOfDay";
45 }
46  
47 2 $res;
48 }
49  
50 2 1;
51 # ABSTRACT: Coerce timeofday from Date::TimeOfDay object
52  
53 __END__
« Coerce/perl/To_date/From_obj/time_moment.pm ↑ Summary Coerce/perl/To_duration/From_str/human.pm »