lib/Pod/Coverage/More/Declared.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 75.0% 3 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 82.9% 34 / 41 CC 6 SCAR 14.8
CC
6
Cov
84%
declarations_for
6.7
BEGIN
1.0
BEGIN
1.0
CRAP 4.4
« blib/lib/Pod/Weaver/Section/Blurbs.pm ↑ Summary blib/lib/Pod/Coverage/More/Blurb.pm »
1 # ABSTRACT: What class builders and signature modules declare about the subs of a package
2 # PODNAME: Pod::Coverage::More::Declared
3  
4 package Pod::Coverage::More::Declared 0.003;
5  
6 24 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 24 ▶use warnings FATAL => q{all};
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 24 ▶use Module::Runtime qw{require_module};
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 # Signatures of single subs first: when a class builder also declares the sub, the signature is more specific.
13 24 our @PROVIDERS = map { "Pod::Coverage::More::Declared::$_" } qw{TypeParams FunctionParameters Kavorka MOP ObjectPad ClassTiny};
14  
15  
16 # The declaration of the invocant of a method, parameter 0, for the providers.
17 # @param name Maybe[Str] the name of the invocant, or undef when it has none
18 # @returns HashRef the declaration of the parameter
19 # @example my $self = Pod::Coverage::More::Declared->invocant('$self');
20 20 ▶sub invocant {
Subroutine invocant: called CC=1 SCAR=0.0
Pod documented
21 20 my ( $class, $name ) = @_;
22 20 return { name => $name, index => 0, type => undef, optional => 0, invocant => 1 };
23 }
24  
25 # The declarations of the subs of C<package> that C<names> lists and a provider declares.
26 # When two providers declare the same sub, the first in PROVIDERS wins, and a C<body> from a later one fills in a missing one.
27 # @param package Str the name of the package
28 # @param names ArrayRef[Str] the names of the subs
29 # @returns HashRef from the name of each declared sub to its declaration
30 # @example my $declared = Pod::Coverage::More::Declared->declarations_for( 'Some::Class', [ 'new', 'size' ] );
31 42 ▶sub declarations_for {
Subroutine declarations_for: called CC=6 SCAR=19.0
Pod documented
32 42 my ( $class, $package, $names ) = @_;
33 42 my %declared;
34 42 foreach my $provider (@PROVIDERS) {
35 252 require_module($provider);
36 252 ▶ next if !$provider->applies_to($package);
Branch: 1 branch
BranchTrueFalseTotal
unless $provider->applies_to($package) 230 22 252
37 22 my $found = $provider->declarations( $package, $names );
38 22 foreach my $name ( keys %$found ) {
39 23 ▶ if ( !$declared{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($declared{$name}) 23 0 23
40 23 $declared{$name} = $found->{$name};
41 23 next;
42 }
43 0 ▶ $declared{$name}{body} //= $found->{$name}{body};
Condition0%0/3
$declared{$name}{"body"} //= $found->{$name}{"body"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$declared{$name}{"body"} //= $found->{$name}{"body"}
$declared{$name}{"body"} $found->{$name}{"body"}
Truth table0%0/3
A //= B
A= $declared{$name}{"body"}B= $found->{$name}{"body"}
ABresult
1X1
011
000
44 }
45 }
46 42 return \%declared;
47 }
48  
49 24 1;
50  
51 __END__
« blib/lib/Pod/Weaver/Section/Blurbs.pm ↑ Summary blib/lib/Pod/Coverage/More/Blurb.pm »