blib/lib/Template/Plugin/Digest/SHA3.pm

filter: Statementstmt 100% 43 / 43 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 100% 58 / 58 CC 2 SCAR 1.5
CC
2
Cov
100%
new
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Template::Plugin::Digest::SHA3;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 $VERSION = 0.01;
8  
9 6 ▶use base qw(Template::Plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Template::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Template::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use Digest::SHA3;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 6 my $sha3;
15  
16 6 $Template::Stash::SCALAR_OPS->{'sha3'} = \&_sha3;
17 6 $Template::Stash::SCALAR_OPS->{'sha3_hex'} = \&_sha3_hex;
18 6 $Template::Stash::SCALAR_OPS->{'sha3_base64'} = \&_sha3_base64;
19  
20 sub new {
21 10 ▶ my ($class, $context, $options) = @_;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
22  
23 10 ▶ my $hashlen = $options || 256;
Condition100%2/2
$options || 256
l!l
37
MC/DC100%1/1
$options || 256
$options
Truth table100%2/2
A
A= $options
Aresult
11
00
24 10 $sha3 = new Digest::SHA3 $hashlen;
25  
26 # now define the filter and return the plugin
27 10 $context->define_filter('sha3', \&_sha3);
28 10 $context->define_filter('sha3_hex', \&_sha3_hex);
29 10 $context->define_filter('sha3_base64', \&_sha3_base64);
30 10 return bless {}, $class;
31 }
32  
33 sub _sha3 {
34 4 ▶ $sha3->reset();
Subroutine _sha3: called CC=1 SCAR=0.0
35 4 $sha3->add(join('', @_));
36 4 return $sha3->digest();
37 }
38  
39 sub _sha3_hex {
40 7 ▶ $sha3->reset();
Subroutine _sha3_hex: called CC=1 SCAR=0.0
41 7 $sha3->add(join('', @_));
42 7 return $sha3->hexdigest();
43 }
44  
45 sub _sha3_base64 {
46 6 ▶ $sha3->reset();
Subroutine _sha3_base64: called CC=1 SCAR=0.0
47 6 $sha3->add(join('', @_));
48 6 return $sha3->b64digest();
49 }
50  
51 6 1;
52  
53 __END__
↑ Summary