Marketing/DateTimeAccessor.pm

filter: Statementstmt 100% 27 / 27 Branchbran 66.6% 4 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 95.6% 44 / 46 CC 5 SCAR 7.5
CC
5
Cov
94%
_force_datetime_object
3.1
set
3.0
BEGIN
1.0
CRAP 2.1
« Marketing.pm ↑ Summary Marketing/Service.pm »
1 package Yahoo::Marketing::DateTimeAccessor;
2 # Copyright (c) 2009 Yahoo! Inc. All rights reserved.
3 # The copyrights to the contents of this file are licensed under the Perl Artistic License (ver. 15 Aug 1997)
4  
5 165 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6 165 ▶use base qw/ Class::Accessor::Chained /;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 165 ▶use DateTime::Format::W3CDTF;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 165 ▶use DateTime::Format::ISO8601;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 39 ▶sub _force_datetime_object {
Subroutine _force_datetime_object: called CC=3 SCAR=11.2
12 39 my ( $self, $value ) = @_;
13  
14 39 ▶ if( defined $value ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 39 0 39
15 39 ▶ unless( ref $value ){ # not a date time object
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value) 39 0 39
16 39 $value = DateTime::Format::ISO8601->new->parse_datetime( $value );
17 }
18 # let's hope it looks like a duck... er, DateTime object
19 39 $value->set_formatter( DateTime::Format::W3CDTF->new );
20 }
21  
22 39 return $value;
23 }
24  
25 619 ▶sub set {
Subroutine set: called CC=3 SCAR=11.0
Pod documented
26 619 my ( $self, $key, @values ) = @_;
27  
28 619 ▶ if ( $key =~ /Date$/ || $key =~ /Timestamp$/ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /Date$/ or $key =~ /Timestamp$/) 39 580 619
Condition100%3/3
$key =~ /Date$/ or $key =~ /Timestamp$/
l!l&&r!l&&!r
930580
MC/DC100%2/2
$key =~ /Date$/ or $key =~ /Timestamp$/
$key =~ /Date$/ $key =~ /Timestamp$/
Truth table100%3/3
A or B
A= $key =~ /Date$/B= $key =~ /Timestamp$/
ABresult
1X1
011
000
29 39 @values = map { $self->_force_datetime_object( $_ ) } @values;
30 }
31  
32 619 $self->SUPER::set( $key, @values );
33 }
34  
35 165 1;
36  
37 __END__
« Marketing.pm ↑ Summary Marketing/Service.pm »