lib/Mail/Pyzor/SHA.pm

filter: Statementstmt 93.1% 27 / 29 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 80.8% 38 / 47 CC 6 SCAR 14.1
CC
6
Cov
82%
_sha_module
6.7
BEGIN
1.0
BEGIN
1.0
CRAP 4.1
« lib/Mail/Pyzor/Client.pm ↑ Summary blib/lib/Mail/Pyzor.pm »
1 package Mail::Pyzor::SHA;
2  
3 # Copyright 2018 cPanel, LLC.
4 # All rights reserved.
5 # http://cpanel.net
6 #
7 # This is free software; you can redistribute it and/or modify it under the
8 # same terms as Perl itself. See L<perlartistic>.
9  
10 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 ▶use constant _ORDER => ( 'Digest::SHA1', 'Digest::SHA' );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 my $_sha_module;
16  
17 sub _sha_module {
18 6 ▶ if ( !$_sha_module ) {
Subroutine _sha_module: called CC=6 SCAR=19.0
Branch: 1 branch
BranchTrueFalseTotal
unless ($_sha_module) 1 5 6
19  
20 # First check if one of the modules is loaded.
21 1 ▶ if ( my @loaded = grep { $_->can('sha1') } _ORDER ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@loaded) = grep({$_->can('sha1');} ('Digest::SHA1', 'Digest::SHA'))) { } 0 1 1
22 0 $_sha_module = $loaded[0];
23 }
24 else {
25 1 local $@;
26  
27 1 my @modules = _ORDER();
28  
29 1 ▶ while ( my $module = shift @modules ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $module = shift @modules) 1 0 1
30 1 my $path = "$module.pm";
31 1 $path =~ s<::></>g;
32  
33 1 ▶ if ( eval { require $path; 1 } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { require $path; 1 } }) { } 1 0 1
elsif (not @modules) { } 0 0 0
34 1 $_sha_module = $module;
35 1 last;
36 }
37 elsif ( !@modules ) {
38 0 die;
39 }
40 }
41 }
42 }
43  
44 6 return $_sha_module;
45 }
46  
47 sub sha1 {
48 2 ▶ return _sha_module()->can('sha1')->(@_);
Subroutine sha1: called CC=1 SCAR=0.0
Pod undocumented
49 }
50  
51 sub sha1_hex {
52 4 ▶ return _sha_module()->can('sha1_hex')->(@_);
Subroutine sha1_hex: called CC=1 SCAR=0.0
Pod undocumented
53 }
54  
55 4 1;
« lib/Mail/Pyzor/Client.pm ↑ Summary blib/lib/Mail/Pyzor.pm »