File Coverage

blib/lib/Enterprise/Licence/Generate.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Enterprise::Licence::Generate;
2 1     1   99694 use utf8; use warnings; use strict;
  1     1   25  
  1     1   6  
  1         30  
  1         2  
  1         24  
  1         5  
  1         2  
  1         22  
3 1     1   438 use parent 'Enterprise::Licence';
  1         287  
  1         6  
4             sub generate {
5 2     2 1 29 my $msg = $_[0]->{ch}->encode([split '', $_[0]->{secret}]);
6 2         137 $msg =~ s/^(0*)//;
7 2         11 my $n = '_' x length $1;
8             my ($dec, $time, $end) = (
9             $_[0]->bin2dec($msg) + $_[0]->bin2dec($_[0]->customer_offset($_[1])),
10             DateTime->now()->epoch(),
11 2         12 DateTime->now()->add(%{ $_[2] })->epoch(),
  2         1842  
12             );
13 2         2255 return sprintf("%s-%s-%s-%s",
14             $_[0]->bi($dec) . $n,
15             $_[0]->bi($time),
16             $_[0]->bi($end),
17             $_[0]->bi($end - $time)
18             );
19             }
20             1;