Object/Metadata/Column/Date.pm

filter: Statementstmt 59.1% 29 / 49 Branchbran 5.0% 1 / 20 Conditioncond 9.5% 2 / 21 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 66.6% 8 / 12 Podpod 66.6% 4 / 6 totaltotal 36.9% 44 / 119 CC 18 SCAR 31.4
CC
18
Cov
36%
parse_value
56.0
method_should_set
30.0
should_inline_value
18.4
CRAP 23.1
« Object/Metadata/Column/Timestamp.pm ↑ Summary Object/Metadata/Relationship/OneToMany.pm »
1 package Rose::DB::Object::Metadata::Column::Date;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 ▶use Rose::DateTime::Util();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Rose::Object::MakeMethods::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Rose::DB::Object::MakeMethods::Date;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use Rose::DB::Object::Metadata::Column;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 our @ISA = qw(Rose::DB::Object::Metadata::Column);
12  
13 4 our $VERSION = '0.788';
14  
15 4 __PACKAGE__->add_common_method_maker_argument_names('default', 'time_zone', 'type');
16  
17 4 Rose::Object::MakeMethods::Generic->make_methods
18 (
19 { preserve_existing => 1 },
20 scalar => [ __PACKAGE__->common_method_maker_argument_names ]
21 );
22  
23 4 foreach my $type (__PACKAGE__->available_method_types)
24 {
25 12 __PACKAGE__->method_maker_class($type => 'Rose::DB::Object::MakeMethods::Date');
26 12 __PACKAGE__->method_maker_type($type => 'date');
27 }
28  
29 10 ▶sub type { 'date' }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
30  
31 sub should_inline_value
32 0 ▶{
Subroutine should_inline_value: not called CC=5 SCAR=29.1
Pod documented
33 0 my($self, $db, $value) = @_;
34 4 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
35 0 ▶ return (($db->validate_date_keyword($value) && $db->should_inline_date_keyword($value)) ||
Branch: 1 branch
BranchTrueFalseTotal
$db->validate_date_keyword($value) && $db->should_inline_date_keyword($value) || $db->keyword_function_calls && $value =~ /^\w+\(.*\)$/ ? : 0 0 0
Condition0%0/9
$db->validate_date_keyword($value) and $db->should_inline_date_keyword($value) or $db->keyword_function_calls and $value =~ /^\w+\(.*\)$/
l!l&&r!l&&!r
000
$db->validate_date_keyword($value) and $db->should_inline_date_keyword($value)
!ll&&!rl&&r
000
$db->keyword_function_calls and $value =~ /^\w+\(.*\)$/
!ll&&!rl&&r
000
MC/DC0%0/4
$db->validate_date_keyword($value) and $db->should_inline_date_keyword($value) or $db->keyword_function_calls and $value =~ /^\w+\(.*\)$/
$db->validate_date_keyword($value) $db->should_inline_date_keyword($value) $db->keyword_function_calls $value =~ /^\w+\(.*\)$/
Truth table0%0/7
A and B or C and D
A= $db->validate_date_keyword($value)B= $db->should_inline_date_keyword($value)C= $db->keyword_function_callsD= $value =~ /^\w+\(.*\)$/
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
36 ($db->keyword_function_calls && $value =~ /^\w+\(.*\)$/)) ? 1 : 0;
37 }
38  
39 sub method_should_set
40 0 ▶{
Subroutine method_should_set: not called CC=5 SCAR=34.0
Pod undocumented
41 0 my($self, $type, $args) = @_;
42  
43 0 ▶ return 1 if($type eq 'set');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "set" 0 0 0
44 0 ▶ return 0 if($type eq 'get');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "get" 0 0 0
45  
46 0 ▶ if($type eq 'get_set')
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "get_set") 0 0 0
47 {
48 # Set with 1 arg, but two args is a form of get.
49 # Three or more args is undefined...
50 0 ▶ return @$args == 2 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
@$args == 2 ? : 0 0 0
51 }
52  
53 0 return $self->SUPER::method_should_set($type, $args);
54 }
55  
56 sub parse_value
57 0 ▶{
Subroutine parse_value: not called CC=7 SCAR=40.3
Pod documented
58 0 my($self, $db) = (shift, shift);
59  
60 0 $self->parse_error(undef);
61  
62 0 my $dt = $db->parse_date(@_);
63  
64 0 ▶ if($dt)
Branch: 1 branch
BranchTrueFalseTotal
if ($dt) { } 0 0 0
65 {
66 0 ▶ $dt->set_time_zone($self->time_zone || $db->server_time_zone)
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($dt, "DateTime") 0 0 0
Condition0%0/3
$self->time_zone || $db->server_time_zone
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->time_zone || $db->server_time_zone
$self->time_zone $db->server_time_zone
Truth table0%0/3
A || B
A= $self->time_zoneB= $db->server_time_zone
ABresult
1X1
011
000
67 if(UNIVERSAL::isa($dt, 'DateTime'));
68 }
69 else
70 {
71 0 ▶ $dt = Rose::DateTime::Util::parse_date($_[0], $self->time_zone || $db->server_time_zone);
Condition0%0/3
$self->time_zone || $db->server_time_zone
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->time_zone || $db->server_time_zone
$self->time_zone $db->server_time_zone
Truth table0%0/3
A || B
A= $self->time_zoneB= $db->server_time_zone
ABresult
1X1
011
000
72  
73 0 ▶ if(my $error = Rose::DateTime::Util->error)
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = "Rose::DateTime::Util"->error) 0 0 0
74 {
75 0 ▶ $self->parse_error("Could not parse value '$_[0]' for column $self: $error")
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] 0 0 0
76 if(defined $_[0]);
77 }
78 }
79  
80 0 return $dt;
81 }
82  
83 0 ▶sub format_value { shift; shift->format_date(@_) }
Subroutine format_value: not called CC=1 SCAR=6.9
Pod documented
84  
85 sub method_uses_formatted_key
86 4 ▶{
Subroutine method_uses_formatted_key: called CC=4 SCAR=18.9
Pod undocumented
87 4 my($self, $type) = @_;
88 4 ▶ return 1 if($type eq 'get' || $type eq 'set' || $type eq 'get_set');
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "get" or $type eq "set" or $type eq "get_set" 4 0 4
Condition33%2/6
$type eq "get" or $type eq "set" or $type eq "get_set"
l!l&&r!l&&!r
040
$type eq "get" or $type eq "set"
l!l&&r!l&&!r
004
MC/DC0%0/3
$type eq "get" or $type eq "set" or $type eq "get_set"
$type eq "get" $type eq "set" $type eq "get_set"
Truth table25%1/4
A or B or C
A= $type eq "get"B= $type eq "set"C= $type eq "get_set"
ABCresult
1XX1
01X1
0011
0000
89 0 return 0;
90 }
91  
92 4 1;
93  
94 __END__
« Object/Metadata/Column/Timestamp.pm ↑ Summary Object/Metadata/Relationship/OneToMany.pm »