File Coverage

blib/lib/Enterprise/Licence/Validate.pm
Criterion Covered Total %
statement 27 28 96.4
branch 6 10 60.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 38 44 86.3


line stmt bran cond sub pod time code
1             package Enterprise::Licence::Validate;
2 1     1   517 use utf8; use warnings; use strict;
  1     1   3  
  1     1   8  
  1         32  
  1         3  
  1         23  
  1         5  
  1         2  
  1         24  
3 1     1   16 use parent 'Enterprise::Licence';
  1         4  
  1         6  
4             sub valid {
5 2     2 0 13 my ($rs, $ns, $es, $ds) = split '-', $_[1];
6 2         20 $rs =~ s/(_*)$//;
7 2         11 my $lc = $_[0]->in($rs) - $_[0]->bin2dec($_[0]->customer_offset($_[2]));
8 2 50       1085 if ($lc) {
9 2         69 my $bin = $_[0]->dec2bin($lc);
10 2         320 $bin = (0 x length $1) . $bin;
11 2         11 my $recovered = $_[0]->{ch}->decode($bin);
12 2 50       401 if ($recovered) {
13 2         8 my $sec = join("", @$recovered);
14 2 50       11 if ($_[0]->{secret} eq $sec) {
15 2         8 my ($ltime, $etime, $dtime) = ($_[0]->in($ns), $_[0]->in($es), $_[0]->in($ds));
16 2 50       27 if (($etime - $ltime) == $dtime) {
17 2 100       7 if ( $etime > time) {
18 1         7 return 1;
19             }
20 1         9 return (0, 1);
21             }
22             }
23             }
24             }
25 0           return (0, 0);
26             }
27             1;