File Coverage

blib/lib/Crypt/Passphrase/Encoder.pm
Criterion Covered Total %
statement 21 23 91.3
branch 2 4 50.0
condition 2 3 66.6
subroutine 6 7 85.7
pod 3 3 100.0
total 34 40 85.0


line stmt bran cond sub pod time code
1             package Crypt::Passphrase::Encoder;
2             $Crypt::Passphrase::Encoder::VERSION = '0.023';
3 7     7   199791 use strict;
  7         16  
  7         326  
4 7     7   34 use warnings;
  7         14  
  7         417  
5              
6 7     7   75 use parent 'Crypt::Passphrase::Validator';
  7         12  
  7         72  
7              
8 7     7   4140 use Crypt::SysRandom;
  7         13079  
  7         1941  
9              
10             sub random_bytes {
11 16     16 1 38 my ($self, $count) = @_;
12 16         176 return Crypt::SysRandom::random_bytes($count);
13             }
14              
15             sub crypt_subtypes;
16              
17             sub accepts_hash {
18 28     28 1 78 my ($self, $hash) = @_;
19 28 50       98 return !!0 if not defined $hash;
20 28   66     146 $self->{accepts_hash} //= do {
21 20 50       103 my $string = join '|', map { quotemeta } $self->crypt_subtypes or return;
  249         591  
22 20         604 qr/ \A \$ (?: $string ) [\$,] /x;
23             };
24 28         406 return scalar $hash =~ $self->{accepts_hash};
25             }
26              
27             sub recode_hash {
28 0     0 1   my ($self, $hash, @args) = @_;
29 0           return $hash;
30             }
31              
32             1;
33              
34             #ABSTRACT: Base class for Crypt::Passphrase encoders
35              
36             __END__