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   513 use utf8; use warnings; use strict;
  1     1   2  
  1     1   9  
  1         33  
  1         2  
  1         23  
  1         5  
  1         2  
  1         42  
3 1     1   12 use parent 'Enterprise::Licence';
  1         5  
  1         7  
4             sub valid {
5 2     2 0 14 my ($rs, $ns, $es, $ds) = split '-', $_[1];
6 2         20 $rs =~ s/(_*)$//;
7 2         16 my $lc = $_[0]->in($rs) - $_[0]->bin2dec($_[0]->customer_offset($_[2]));
8 2 50       1143 if ($lc) {
9 2         74 my $bin = $_[0]->dec2bin($lc);
10 2         329 $bin = (0 x length $1) . $bin;
11 2         22 my $recovered = $_[0]->{ch}->decode($bin);
12 2 50       387 if ($recovered) {
13 2         7 my $sec = join("", @$recovered);
14 2 50       9 if ($_[0]->{secret} eq $sec) {
15 2         11 my ($ltime, $etime, $dtime) = ($_[0]->in($ns), $_[0]->in($es), $_[0]->in($ds));
16 2 50       39 if (($etime - $ltime) == $dtime) {
17 2 100       10 if ( $etime > time) {
18 1         9 return 1;
19             }
20 1         8 return (0, 1);
21             }
22             }
23             }
24             }
25 0           return (0, 0);
26             }
27             1;