lib/Crypt/Perl/X/Base.pm

filter: Statementstmt 93.9% 31 / 33 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 82.1% 46 / 56 CC 5 SCAR 5.5
CC
5
Cov
90%
_check_overload
3.0
new
2.0
get
2.0
CRAP 1.7
« lib/Crypt/Perl/ECDSA/PrivateKey.pm ↑ Summary lib/Crypt/Perl/RSA/PrivateKey.pm »
1 package Crypt::Perl::X::Base;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 1212 ▶ my ( $class, $string, $props_hr ) = @_;
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
10  
11 1212 $class->_check_overload();
12  
13 1212 ▶ my %attrs = $props_hr ? %$props_hr : ();
Branch: 1 branch
BranchTrueFalseTotal
$props_hr ? : 812 400 1212
14  
15 1212 return bless [ $string, \%attrs ], $class;
16 }
17  
18 sub get {
19 0 ▶ my ( $self, $attr ) = @_;
Subroutine get: not called CC=1 SCAR=6.9
Pod undocumented
20  
21 #Do we need to clone this? Could JSON suffice, or do we need Clone?
22 0 return $self->[1]{$attr};
23 }
24  
25 sub to_string {
26 320 ▶ my ($self) = @_;
Subroutine to_string: called CC=1 SCAR=0.0
Pod undocumented
27  
28 320 return sprintf '%s: %s', ref($self), $self->[0];
29 }
30  
31 #----------------------------------------------------------------------
32  
33 10 my %_OVERLOADED;
34  
35 sub _check_overload {
36 1212 ▶ my ( $class, $str ) = @_;
Subroutine _check_overload: called CC=3 SCAR=11.1
37  
38 #cf. eval_bug.readme
39 1212 my $eval_err = $@;
40  
41 10 ▶ $_OVERLOADED{$class} ||= eval qq{
Subroutine BEGIN: called CC=1 SCAR=0.0
Condition66%2/3
$_OVERLOADED{$class} ||= eval qq[\n package $class;\n use overload (q<""> => __PACKAGE__->can('__spew'));\n 1;\n ]
l!l&&r!l&&!r
1194180
MC/DC0%0/2
$_OVERLOADED{$class} ||= eval qq[\n package $class;\n use overload (q<""> => __PACKAGE__->can('__spew'));\n 1;\n ]
$_OVERLOADED{$class} eval qq[\n package $class;\n use overload (q<""> => __PACKAGE__->can('__spew'));\n 1;\n ]
Truth table66%2/3
A ||= B
A= $_OVERLOADED{$class}B= eval qq[\n package $class;\n use overload (q<""> => __PACKAGE__->can('__spew'));\n 1;\n ]
ABresult
1X1
011
000
42 package $class;
43 use overload (q<""> => __PACKAGE__->can('__spew'));
44 1;
45 };
46  
47 #Should never happen as long as overload.pm is available.
48 1212 ▶ warn if !$_OVERLOADED{$class};
Branch: 1 branch
BranchTrueFalseTotal
unless $_OVERLOADED{$class} 0 1212 1212
49  
50 1212 $@ = $eval_err;
51  
52 1212 return;
53 }
54  
55 sub __spew {
56 38 ▶ my ($self) = @_;
Subroutine __spew: called CC=2 SCAR=6.9
57  
58 38 my $spew = $self->to_string();
59  
60 38 ▶ if ( substr( $spew, -1 ) ne "\n" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($spew, -1) ne "\n") 1 37 38
61 1 $spew .= Carp::longmess();
62 }
63  
64 38 return $spew;
65 }
66  
67 10 1;
« lib/Crypt/Perl/ECDSA/PrivateKey.pm ↑ Summary lib/Crypt/Perl/RSA/PrivateKey.pm »