File Coverage

blib/lib/Authen/Simple.pm
Criterion Covered Total %
statement 21 21 100.0
branch 3 4 75.0
condition 2 6 33.3
subroutine 5 5 100.0
pod 2 2 100.0
total 33 38 86.8


line stmt bran cond sub pod time code
1             package Authen::Simple;
2              
3 2     2   3071 use strict;
  2         5  
  2         70  
4 2     2   12 use warnings;
  2         4  
  2         64  
5              
6 2     2   2887 use Params::Validate qw[];
  2         26010  
  2         514  
7              
8             our $VERSION = '0.5';
9              
10             sub new {
11 1     1 1 3 my $class = shift;
12              
13 1         5 my %adapter = (
14             isa => 'Authen::Simple::Adapter',
15             type => Params::Validate::OBJECT,
16             optional => 1
17             );
18              
19 1         8 my @spec = ( { %adapter, optional => 0 }, ( \%adapter ) x @_ );
20 1         28 my $adapters = Params::Validate::validate_pos( @_, @spec );
21              
22 1         7 return bless( $adapters, $class );
23             }
24              
25             sub authenticate {
26 2     2 1 991 my ( $self, $username, $password ) = @_;
27              
28 2         4 foreach ( $username, $password ) {
29 4 50 33     84 return 0 unless defined($_) && !ref($_) && length($_);
      33        
30             }
31              
32 2         5 foreach my $adapter ( @{$self} ) {
  2         4  
33 4 100       18 return 1 if $adapter->authenticate( $username, $password );
34             }
35              
36 1         6 return 0;
37             }
38              
39             1;
40              
41             __END__