blib/lib/Class/MakeMethods/Attribute.pm

filter: Statementstmt 93.0% 40 / 43 Branchbran 56.2% 9 / 16 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 75.6% 59 / 78 CC 11 SCAR 17.5
CC
11
Cov
78%
MakeMethod
9.7
import
4.9
BEGIN
1.0
CRAP 5.7
« blib/lib/Class/MakeMethods/Emulator/Struct.pm ↑ Summary blib/lib/Class/MakeMethods/Emulator.pm »
1 package Class::MakeMethods::Attribute;
2  
3 1 require 5.006;
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Attribute::Handlers;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Class::MakeMethods;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Class::MakeMethods::Utility::Inheritable 'get_vvalue';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = 1.005;
12  
13 1 our %DefaultMaker;
14  
15 1 ▶sub import {
Subroutine import: called CC=4 SCAR=15.9
16 1 my $class = shift;
17  
18 1 ▶ if ( scalar @_ and $_[0] =~ m/^\d/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ and $_[0] =~ /^\d/) 0 1 1
Condition33%1/3
scalar @_ and $_[0] =~ /^\d/
!ll&&!rl&&r
010
MC/DC0%0/2
scalar @_ and $_[0] =~ /^\d/
scalar @_ $_[0] =~ /^\d/
Truth table33%1/3
A and B
A= scalar @_B= $_[0] =~ /^\d/
ABresult
0X0
100
111
19 0 Class::MakeMethods::_import_version( $class, shift );
20 }
21
22 1 ▶ if ( scalar @_ == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ == 1) 1 0 1
23 1 my $target_class = ( caller(0) )[0];
24 1 $DefaultMaker{ $target_class } = shift;
25 }
26 }
27  
28 4 ▶sub UNIVERSAL::MakeMethod :ATTR(CODE) {
Subroutine MakeMethod: called CC=8 SCAR=22.8
Pod undocumented
29 4 my ($package, $symbol, $referent, $attr, $data) = @_;
30 4 ▶ if ( $symbol eq 'ANON' or $symbol eq 'LEXICAL' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol eq "ANON" or $symbol eq "LEXICAL") 0 4 4
Condition33%1/3
$symbol eq "ANON" or $symbol eq "LEXICAL"
l!l&&r!l&&!r
004
MC/DC0%0/2
$symbol eq "ANON" or $symbol eq "LEXICAL"
$symbol eq "ANON" $symbol eq "LEXICAL"
Truth table33%1/3
A or B
A= $symbol eq "ANON"B= $symbol eq "LEXICAL"
ABresult
1X1
011
000
31 0 croak "Can't apply MakeMethod attribute to $symbol declaration."
32 }
33 4 ▶ if ( ! $data ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($data) 0 4 4
34 0 croak "No method type provided for MakeMethod attribute."
35 }
36 4 my $symname = *{$symbol}{NAME};
37 4 ▶ if ( ref $data eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "ARRAY") 4 0 4
38 4 local $_ = shift @$data;
39 4 $symname = [ @$data, $symname ];
40 4 $data = $_;
41 }
42 4 ▶ unless ( $DefaultMaker{$package} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Class::MakeMethods::Attribute::DefaultMaker{$package}) 1 3 4
43 1 local $_ = get_vvalue( \%DefaultMaker, $package );
44 1 ▶ $DefaultMaker{$package} = $_ if ( $_ );
Branch: 1 branch
BranchTrueFalseTotal
if $_ 1 0 1
45 }
46 Class::MakeMethods->make(
47 -TargetClass => $package,
48 -ForceInstall => 1,
49 4 ▶ ( $DefaultMaker{$package} ? ('-MakerClass'=>$DefaultMaker{$package}) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$Class::MakeMethods::Attribute::DefaultMaker{$package} ? : 4 0 4
50 $data => $symname
51 );
52 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
53  
54 1 1;
55  
56 __END__
« blib/lib/Class/MakeMethods/Emulator/Struct.pm ↑ Summary blib/lib/Class/MakeMethods/Emulator.pm »