File Coverage

blib/lib/CMS/Drupal/Modules/MembershipEntity/Term.pm
Criterion Covered Total %
statement 22 22 100.0
branch 8 8 100.0
condition 6 6 100.0
subroutine 8 8 100.0
pod 4 4 100.0
total 48 48 100.0


line stmt bran cond sub pod time code
1             package CMS::Drupal::Modules::MembershipEntity::Term;
2             $CMS::Drupal::Modules::MembershipEntity::Term::VERSION = '0.96';
3             # ABSTRACT: Perl interface to a Drupal MembershipEntity membership term
4              
5 10     10   48 use strict;
  10         22  
  10         234  
6 10     10   48 use warnings;
  10         17  
  10         227  
7              
8 10     10   46 use Moo;
  10         17  
  10         56  
9 10     10   2966 use Types::Standard qw/ :all /;
  10         20  
  10         100  
10              
11             has tid => ( is => 'ro', isa => Int, required => 1 );
12             has mid => ( is => 'ro', isa => Int, required => 1 );
13             has status => ( is => 'ro', isa => Int, required => 1 );
14             has term => ( is => 'ro', isa => Str, required => 1 );
15             has modifiers => ( is => 'ro', isa => Str, required => 1 );
16             has start => ( is => 'ro', isa => Int, required => 1 );
17             has end => ( is => 'ro', isa => Int, required => 1 );
18             has array_position => ( is => 'ro', isa => Int, required => 1 );
19              
20             sub is_active {
21 6     6 1 37905 my $self = shift;
22 6 100       49 return $self->{'status'} eq '1'
23             ? 1 : 0;
24             }
25              
26             sub is_current {
27 38     38 1 1824 my $self = shift;
28 38         51 my $now = time;
29 38 100 100     265 return ( $self->{'start'} <= $now and $self->{'end'} > $now )
30             ? 1 : 0;
31             }
32              
33             sub is_future {
34 10     10 1 21 my $self = shift;
35 10         22 my $now = time;
36 10 100 100     143 return ($self->{'start'} > $now and $self->{'end'} > $self->{'start'})
37             ? 1 : 0;
38             }
39              
40             sub was_renewal {
41 16     16 1 2005 my $self = shift;
42 16 100       86 return ($self->{'array_position'} > 1)
43             ? 1 : 0;
44             }
45              
46             1; ## return true to end package MembershipEntity::Term
47              
48             __END__