| 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
| |||||||||||||||||||||
| 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 ]
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 ]
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 61 | 1 | $spew .= Carp::longmess(); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 38 | return $spew; | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 10 | 1; | |||||||||||||||||||