OurCal/Span.pm

filter: Statementstmt 29.4% 10 / 34 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 37.5% 3 / 8 Podpod 100% 3 / 3 totaltotal 32.6% 16 / 49 CC 4 SCAR 21.1
CC
4
Cov
26%
new
20.0
date
2.0
calendar
2.0
CRAP 8.3
« OurCal/Provider/Cache.pm ↑ Summary OurCal.pm »
1 package OurCal::Span;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 =head1 NAME
9  
10 OurCal::Span - a base class for OurCal spans of time
11  
12 =head1 METHODS
13  
14 =head2 new <param[s]>
15  
16 Must have a date param
17  
18 =cut
19  
20 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod documented
21 0 my ($class, %what) = @_;
22 0 my $self = bless \%what, $class;
23 0 ▶ confess "No date set" unless defined $self->date;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->date 0 0 0
24 0 my @names = qw(year month day);
25 0 my @bits = split /-/, $self->date;
26 0 my %opts;
27 0 foreach my $name (@names) {
28 0 my $val = shift @bits;
29 0 ▶ last unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
30 0 $opts{$name} = $val;
31 }
32 0 $self->{_dt} = DateTime->new( %opts );
33 0 return $self;
34 }
35  
36 =head2 date
37  
38 The date for this span
39  
40 =cut
41  
42 0 ▶sub date {
Subroutine date: not called CC=1 SCAR=6.9
Pod documented
43 0 my $self = shift;
44 0 return $self->{date};
45 }
46  
47 =head2 calendar
48  
49 Return the OurCal calendar object this is attached to
50  
51 =cut
52  
53 0 ▶sub calendar {
Subroutine calendar: not called CC=1 SCAR=6.9
Pod documented
54 0 my $self = shift;
55 0 return $self->{calendar};
56 }
57  
58  
59 0 ▶sub _span {
Subroutine _span: not called CC=1 SCAR=6.9
60 0 my $self = shift;
61 0 my $class = shift;
62 0 my $date = shift;
63 # TODO this needs to be abstracted
64 0 my %what = ( date => $date, calendar => $self->calendar );
65 0 return $class->new(%what);
66 }
67  
68 0 ▶sub _shift {
Subroutine _shift: not called CC=1 SCAR=6.9
69 0 my $self = shift;
70 0 my $date = shift;
71 0 my $prev = ref($self)->new( date => $date, calendar => $self->calendar );
72 }
73  
74  
75  
76 2 1;
« OurCal/Provider/Cache.pm ↑ Summary OurCal.pm »