File Coverage

blib/lib/Salvation/TC/Type/Time.pm
Criterion Covered Total %
statement 9 19 47.3
branch 0 10 0.0
condition 0 14 0.0
subroutine 3 4 75.0
pod 1 1 100.0
total 13 48 27.0


line stmt bran cond sub pod time code
1             package Salvation::TC::Type::Time;
2              
3 4     4   12 use strict;
  4         4  
  4         101  
4 4     4   12 use warnings;
  4         4  
  4         74  
5              
6 4     4   11 use base 'Salvation::TC::Type';
  4         4  
  4         804  
7              
8             my $re = qr/^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/;
9              
10             sub Check {
11              
12 0     0 1   my ( $class, $time ) = @_;
13              
14 0           eval {
15              
16 0 0 0       die 'Wrong time format.' if ( ! defined( $time ) || $time !~ $re );
17              
18 0           my ( $hours, $minutes, $seconds ) = ( $1, $2, $3 );
19              
20 0   0       $seconds ||= '00';
21              
22 0 0 0       die "Hours must be bettween 0 and 23. Current value is $hours." unless int( $hours ) >= 0 && int( $hours ) <= 23;
23 0 0 0       die "Minutes must be bettween 0 and 23. Current value is $minutes." unless int( $minutes ) >= 0 && int( $minutes ) <= 59;
24 0 0 0       die "Seconds must be bettween 0 and 23. Current value is $seconds." unless int( $seconds ) >= 0 && int( $seconds ) <= 59;
25             };
26              
27 0 0         if( $@ ) {
28              
29 0           Salvation::TC::Exception::WrongType -> throw( type => 'Time', value => $time );
30             };
31             }
32              
33             1;
34             __END__