File Coverage

blib/lib/Password/Policy/Rule/Length.pm
Criterion Covered Total %
statement 26 27 96.3
branch 5 6 83.3
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 38 42 90.4


line stmt bran cond sub pod time code
1             package Password::Policy::Rule::Length;
2             $Password::Policy::Rule::Length::VERSION = '0.06';
3 4     4   517859 use strict;
  4         9  
  4         182  
4 4     4   22 use warnings;
  4         11  
  4         294  
5              
6 4     4   776 use parent 'Password::Policy::Rule';
  4         672  
  4         26  
7              
8 4     4   2980 use String::Multibyte;
  4         23712  
  4         376  
9              
10 4     4   2274 use Password::Policy::Exception::InsufficientLength;
  4         14  
  4         673  
11              
12 2     2 0 16 sub default_arg { return 8; }
13              
14             sub check {
15 20     20 0 10952 my $self = shift;
16 20         76 my $password = $self->prepare(shift);
17 19         87 my $strmb = String::Multibyte->new('UTF8');
18 19 100       19256 if($strmb->islegal($password)) {
19 18         483 my $len = $strmb->length($password);
20 18 100       362 if($len < $self->arg) {
21 4         52 Password::Policy::Exception::InsufficientLength->throw;
22             }
23             } else {
24 1         39 my $len = length $password;
25 1 50       12 if($len < $self->arg) {
26 0         0 Password::Policy::Exception::InsufficientLength->throw;
27             }
28             }
29 15         221 return 1;
30             }
31              
32             1;
33              
34             __END__