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 0 1 0.0
total 23 24 95.8


line stmt bran cond sub pod time code
1             package Enterprise::Licence::Generate;
2 1     1   105427 use utf8; use warnings; use strict;
  1     1   25  
  1     1   7  
  1         31  
  1         2  
  1         26  
  1         5  
  1         2  
  1         24  
3 1     1   439 use parent 'Enterprise::Licence';
  1         294  
  1         6  
4             sub generate {
5 2     2 0 40 my $msg = $_[0]->{ch}->encode([split '', $_[0]->{secret}]);
6 2         142 $msg =~ s/^(0*)//;
7 2         10 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         11 DateTime->now()->add(%{ $_[2] })->epoch(),
  2         2089  
12             );
13 2         2495 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;