IPMessenger/EncryptOption.pm

filter: Statementstmt 39.4% 15 / 38 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 57.1% 4 / 7 Podpod 100% 2 / 2 totaltotal 32.8% 21 / 64 CC 9 SCAR 33.6
CC
9
Cov
28%
AUTOLOAD
56.0
new
12.0
get_option
2.0
CRAP 28.9
« IPMessenger.pm ↑ Summary IPMessenger/CommandLine.pm »
1 package Net::IPMessenger::EncryptOption;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use overload '""' => \&get_option, fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Scalar::Util qw( looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $AUTOLOAD;
9  
10 2 my %ENCRYPT_OPT = (
11 RSA_512 => 0x00000001,
12 RSA_1024 => 0x00000002,
13 RSA_2048 => 0x00000004,
14 RC2_40 => 0x00001000,
15 RC2_128 => 0x00004000,
16 RC2_256 => 0x00008000,
17 BLOWFISH_128 => 0x00020000,
18 BLOWFISH_256 => 0x00040000,
19 SIGN_MD5 => 0x10000000,
20 RC2_40OLD => 0x00000010,
21 RC2_128OLD => 0x00000040,
22 BLOWFISH_128OLD => 0x00000400,
23 );
24  
25 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
26 0 my $class = shift;
27 0 ▶ my $option = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
28  
29 0 ▶ return unless looks_like_number($option);
Branch: 1 branch
BranchTrueFalseTotal
unless &looks_like_number($option) 0 0 0
30 0 my $self = { _option => $option };
31 0 bless $self, $class;
32 }
33  
34 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=7 SCAR=40.3
35 0 my $self = shift;
36 0 ▶ return unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
37  
38 0 my $option = $self->{_option};
39 0 my $name = $AUTOLOAD;
40 0 $name =~ s/.*://;
41  
42 0 ▶ if ( $name =~ /^get_(.+)/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($name =~ /^get_(.+)/) { } 0 0 0
elsif ($name =~ /^set_(.+)/) { } 0 0 0
43 0 my $enc = uc $1;
44 0 ▶ if ( exists $ENCRYPT_OPT{$enc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENCRYPT_OPT{$enc}) { } 0 0 0
45 0 ▶ return ( $option & $ENCRYPT_OPT{$enc} ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$option & $ENCRYPT_OPT{$enc} ? : 0 0 0
46 }
47 else {
48 0 return;
49 }
50 }
51 elsif ( $name =~ /^set_(.+)/ ) {
52 0 my $enc = uc $1;
53 0 ▶ if ( exists $ENCRYPT_OPT{$enc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENCRYPT_OPT{$enc}) { } 0 0 0
54 0 $self->{_option} = $option | $ENCRYPT_OPT{$enc};
55 0 return $self;
56 }
57 else {
58 0 return;
59 }
60 }
61 else {
62 0 return;
63 }
64 }
65  
66 0 ▶sub get_option {
Subroutine get_option: not called CC=1 SCAR=6.9
Pod documented
67 0 my $self = shift;
68 0 return $self->{_option};
69 }
70  
71 2 1;
72 __END__
« IPMessenger.pm ↑ Summary IPMessenger/CommandLine.pm »