blib/lib/perl5i/2/Signature.pm

filter: Statementstmt 69.2% 27 / 39 Branchbran 50.0% 3 / 6 Conditioncond 57.1% 4 / 7 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 63.6% 7 / 11 Podpod 0.0% 0 / 3 totaltotal 60.0% 42 / 70 SCAR 22.0
CC
7
Cov
65%
new
6.3
AUTOLOAD
6.0
__ANON__
2.0
CRAP 9.0
« blib/lib/perl5i/0/DEFAULT.pm ↑ Summary blib/lib/perl5i/1/HASH.pm »
1 package perl5i::2::Signature;
2  
3 109 ▶use 5.010_000;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 109 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 109 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 109 ▶use perl5i::2::Signature::Method::None;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 109 ▶use perl5i::2::Signature::Function::None;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # A proxy class to hold a method's signature until its actually used.
11  
12 use overload
13 0 ▶ q[""] => sub { return $_[0]->as_string },
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 109 fallback => 1
15 109 ▶;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17  
18 sub new {
19 2071 ▶ my $class = shift;
Subroutine new: called CC=6 SCAR=18.5
Pod undocumented
20 2071 my %args = @_;
21  
22 2071 ▶ my $string = $args{signature} // '';
Condition50%1/2
$args{"signature"} // ""
l!l
20710
MC/DC0%0/1
$args{"signature"} // ""
$args{"signature"}
Truth table50%1/2
A
A= $args{"signature"}
Aresult
11
00
23 2071 ▶ my $is_method = $args{is_method} // 0;
Condition50%1/2
$args{"is_method"} // 0
l!l
20710
MC/DC0%0/1
$args{"is_method"} // 0
$args{"is_method"}
Truth table50%1/2
A
A= $args{"is_method"}
Aresult
11
00
24  
25 2071 ▶ my $no_params = !$string || $string !~ /\S/;
Condition66%2/3
$string && $string =~ /\S/
!ll&&!rl&&r
21801853
MC/DC50%1/2
$string && $string =~ /\S/
$string $string =~ /\S/
Truth table66%2/3
A && B
A= $stringB= $string =~ /\S/
ABresult
0X0
100
111
26 2071 ▶ if( $no_params ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($no_params) { } 218 1853 2071
27 218 ▶ return $is_method ? perl5i::2::Signature::Method::None->new( signature => $string )
Branch: 1 branch
BranchTrueFalseTotal
$is_method ? : 218 0 218
28 : perl5i::2::Signature::Function::None->new( signature => $string );
29 }
30 else {
31 1853 return bless { signature => $string, is_method => $is_method }, $class;
32 }
33 }
34  
35 sub as_string {
36 0 ▶ my $self = shift;
Subroutine as_string: not called CC=1 SCAR=6.9
Pod undocumented
37 0 return $self->{signature};
38 }
39  
40 sub make_real {
41 0 ▶ my $self = shift;
Subroutine make_real: not called CC=1 SCAR=6.9
Pod undocumented
42  
43 0 require perl5i::2::Signature::Real;
44 0 bless $self, "perl5i::2::Signature::Real";
45  
46 0 $self->__parse_signature;
47 }
48  
49 # Upgrade to a real signature object
50 # and call the original method.
51 # This should only be called once per object.
52 109 our $AUTOLOAD;
53 sub AUTOLOAD {
54 0 ▶ my($method) = reverse split /::/, $AUTOLOAD;
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
55 0 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 0 0 0
56  
57 0 my $self = $_[0]; # leave @_ alone
58  
59 # Upgrade to a real object
60 0 $self->make_real;
61  
62 0 goto $self->can($method);
63 }
64  
65 109 1;
« blib/lib/perl5i/0/DEFAULT.pm ↑ Summary blib/lib/perl5i/1/HASH.pm »