lib/Pod/Coverage/More/Declared/ClassTiny.pm

filter: Statementstmt 92.3% 24 / 26 Branchbran 66.6% 4 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 91.1% 41 / 45 CC 6 SCAR 10.0
CC
6
Cov
89%
declarations
4.2
applies_to
3.0
BEGIN
1.0
CRAP 2.7
« lib/Pod/Coverage/More/Declared/ObjectPad.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/Test/Pod/Coverage/More.pm »
1 # ABSTRACT: Declarations of the attributes of Class::Tiny classes
2 # PODNAME: Pod::Coverage::More::Declared::ClassTiny
3  
4 package Pod::Coverage::More::Declared::ClassTiny 0.003;
5  
6 13 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use warnings FATAL => q{all};
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 13 ▶use Pod::Coverage::More::Declared;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 ▶use Types::Standard qw{InstanceOf};
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 # Whether L<Class::Tiny> built C<package>.
15 # @param package Str the name of the package
16 # @returns Bool
17 # @example next if !Pod::Coverage::More::Declared::ClassTiny->applies_to('Some::Class');
18 42 ▶sub applies_to {
Subroutine applies_to: called CC=3 SCAR=11.0
Pod documented
19 42 my ( $class, $package ) = @_;
20 42 ▶ return ( $INC{'Class/Tiny.pm'} && $package->isa('Class::Tiny::Object') ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$INC{'Class/Tiny.pm'} && $package->isa('Class::Tiny::Object') ? : 1 41 42
Condition100%3/3
$INC{"Class/Tiny.pm"} and $package->isa("Class::Tiny::Object")
!ll&&!rl&&r
3651
MC/DC100%2/2
$INC{"Class/Tiny.pm"} and $package->isa("Class::Tiny::Object")
$INC{"Class/Tiny.pm"} $package->isa("Class::Tiny::Object")
Truth table100%3/3
A and B
A= $INC{"Class/Tiny.pm"}B= $package->isa("Class::Tiny::Object")
ABresult
0X0
100
111
21 }
22  
23 # The declarations of the subs of C<package> that C<names> lists, as L<Pod::Coverage::More::Declared> describes them.
24 # @param package Str the name of the package
25 # @param names ArrayRef[Str] the names of the subs
26 # @returns HashRef from the name of each declared sub to its declaration
27 # @example my $declared = Pod::Coverage::More::Declared::ClassTiny->declarations( 'Some::Class', ['new'] );
28 1 ▶sub declarations {
Subroutine declarations: called CC=4 SCAR=14.5
Pod documented
29 1 my ( $class, $package, $names ) = @_;
30 1 my %own = map { $_ => 1 } @$names;
31 1 my @attributes = Class::Tiny->get_all_attributes_for($package);
32 1 my %declared;
33  
34 1 foreach my $attribute (@attributes) {
35 2 ▶ next if !$own{$attribute};
Branch: 1 branch
BranchTrueFalseTotal
unless $own{$attribute} 0 2 2
36 2 $declared{$attribute} = {
37 via => 'Class::Tiny',
38 role => 'accessor',
39 attribute => $attribute,
40 params => [
41 Pod::Coverage::More::Declared->invocant,
42 { name => undef, index => 1, type => undef, optional => 1, invocant => 0 },
43 ],
44 returns => [],
45 };
46 }
47 1 ▶ if ( $own{new} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($own{"new"}) 0 1 1
48 $declared{new} = {
49 via => 'Class::Tiny',
50 role => 'constructor',
51 params => [
52 Pod::Coverage::More::Declared->invocant,
53 0 map { { name => undef, named => $_, type => undef, optional => 1, invocant => 0 } } @attributes,
54 ],
55 returns => [ InstanceOf [$package] ],
56 };
57 }
58 1 return \%declared;
59 }
60  
61 13 1;
62  
63 __END__
« lib/Pod/Coverage/More/Declared/ObjectPad.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/Test/Pod/Coverage/More.pm »