Nested/Validator/DateTime.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 10 / 10 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 95.0% 58 / 61 CC 8 SCAR 10.5
CC
8
Cov
100%
greater_than_equal
4.0
greater_than
4.0
date
2.0
CRAP 2.9
« Nested/Profile.pm ↑ Summary Nested/ProfileProvider.pm »
1 package FormValidator::Nested::Validator::DateTime;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 23 ▶sub date {
Subroutine date: called CC=2 SCAR=6.9
Pod undocumented
9 23 my ( $value, $options, $req ) = @_;
10  
11 23 ▶ if ( blessed $value ne 'DateTime' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) ne "DateTime") 7 16 23
12 7 return 0;
13 }
14 16 return 1;
15 }
16  
17 5 ▶sub greater_than_equal {
Subroutine greater_than_equal: called CC=4 SCAR=13.9
Pod undocumented
18 5 my ( $value, $options, $req ) = @_;
19  
20 5 my $target_dt = $req->param($options->{target});
21  
22 5 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless (date($value, $options, $req) and date($target_dt, $options, $req)) 2 3 5
Condition100%3/3
date($value, $options, $req) and date($target_dt, $options, $req)
!ll&&!rl&&r
113
MC/DC100%2/2
date($value, $options, $req) and date($target_dt, $options, $req)
date($value, $options, $req) date($target_dt, $options, $req)
Truth table100%3/3
A and B
A= date($value, $options, $req)B= date($target_dt, $options, $req)
ABresult
0X0
100
111
23 !date($value, $options, $req)
24 || !date($target_dt, $options, $req)
25 ) {
26 # 日付形式不具合もokとする
27 2 return 1;
28 }
29  
30 3 ▶ if ( $value < $target_dt ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value < $target_dt) 1 2 3
31 1 return 0;
32 }
33 2 return 1;
34 }
35  
36 5 ▶sub greater_than {
Subroutine greater_than: called CC=4 SCAR=13.9
Pod undocumented
37 5 my ( $value, $options, $req ) = @_;
38  
39 5 my $target_dt = $req->param($options->{target});
40  
41 5 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless (date($value, $options, $req) and date($target_dt, $options, $req)) 2 3 5
Condition100%3/3
date($value, $options, $req) and date($target_dt, $options, $req)
!ll&&!rl&&r
113
MC/DC100%2/2
date($value, $options, $req) and date($target_dt, $options, $req)
date($value, $options, $req) date($target_dt, $options, $req)
Truth table100%3/3
A and B
A= date($value, $options, $req)B= date($target_dt, $options, $req)
ABresult
0X0
100
111
42 !date($value, $options, $req)
43 || !date($target_dt, $options, $req)
44 ) {
45 # 日付形式不具合もokとする
46 2 return 1;
47 }
48  
49 3 ▶ if ( $value <= $target_dt ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value <= $target_dt) 2 1 3
50 2 return 0;
51 }
52 1 return 1;
53 }
54  
55  
56 3 1;
57  
« Nested/Profile.pm ↑ Summary Nested/ProfileProvider.pm »