Shadow/Role.pm

filter: Statementstmt 100% 42 / 42 Branchbran 100% 6 / 6 Conditioncond 83.3% 5 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 12 / 12 Podpod 100% 5 / 5 totaltotal 97.3% 72 / 74 CC 6 SCAR 10.2
CC
6
Cov
98%
new_from_attrs
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
« Shadow.pm ↑ Summary
1 package MooX::Attributes::Shadow::Role;
2  
3 # ABSTRACT: enumerate shadowable attributes in a contained class
4  
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 our $VERSION = '0.05';
8  
9 5 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 ▶use MooX::Attributes::Shadow;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # make sure we have symbols in this package, so namespace clean test passes.
16 8 ▶sub shadow_attrs { goto \&MooX::Attributes::Shadow::shadow_attrs };
Subroutine shadow_attrs: called CC=1 SCAR=0.0
Pod documented
17 2 ▶sub shadowed_attrs { goto \&MooX::Attributes::Shadow::shadowed_attrs };
Subroutine shadowed_attrs: called CC=1 SCAR=0.0
Pod documented
18 9 ▶sub xtract_attrs { goto \&MooX::Attributes::Shadow::xtract_attrs };
Subroutine xtract_attrs: called CC=1 SCAR=0.0
Pod documented
19  
20 ## no critic (ProhibitSubroutinePrototypes)
21 4 ▶sub shadowable_attrs (@) {
Subroutine shadowable_attrs: called CC=1 SCAR=0.0
Pod documented
22  
23 4 my $attrs = [@_];
24  
25 ## no critic (ProhibitNoStrict)
26 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 4 ▶ *{ caller() . '::shadowable_attrs' } = sub (@) { @{$attrs} };
Subroutine __ANON__: called CC=1 SCAR=0.0
30  
31 4 return;
32 }
33  
34 5 ▶sub new_from_attrs (@) {
Subroutine new_from_attrs: called CC=6 SCAR=17.9
Pod documented
35  
36 5 my $contained = shift;
37  
38 5 my $container = shift;
39  
40 # handle the following cases:
41 # @args = ( \%options );
42 # @args = ( \%options, %attr );
43 # @args = ( \%options, \%attrs );
44 # @args = ( %attr );
45  
46 5 my $options = {};
47 5 my %attrs;
48  
49 5 ▶ if ( @_ == 1 ) {
Branch: 3 branches
BranchTrueFalseTotal
if (@_ == 1) { } 1 4 5
elsif (@_ == 2 and 'HASH' eq ref $_[0] and 'HASH' eq ref $_[1]) { } 1 3 4
elsif (@_ % 2) { } 1 2 3
50  
51 1 $options = shift;
52  
53 }
54  
55 ▶ elsif ( @_ == 2 && 'HASH' eq ref $_[0] && 'HASH' eq ref $_[1] ) {
Condition83%5/6
@_ == 2 and "HASH" eq ref $_[0] and "HASH" eq ref $_[1]
!ll&&!rl&&r
301
@_ == 2 and "HASH" eq ref $_[0]
!ll&&!rl&&r
211
MC/DC66%2/3
@_ == 2 and "HASH" eq ref $_[0] and "HASH" eq ref $_[1]
@_ == 2 "HASH" eq ref $_[0] "HASH" eq ref $_[1]
Truth table75%3/4
A and B and C
A= @_ == 2B= "HASH" eq ref $_[0]C= "HASH" eq ref $_[1]
ABCresult
0XX0
10X0
1100
1111
56  
57 1 $options = shift;
58 1 %attrs = %{ shift() };
59  
60 }
61  
62 elsif ( @_ % 2 ) {
63  
64 1 $options = shift;
65 1 %attrs = @_;
66  
67 }
68  
69 else {
70  
71 2 %attrs = @_;
72  
73 }
74  
75 5 return $contained->new( $contained->xtract_attrs( $container, $options ), %attrs );
76 }
77  
78 5 1;
79  
80 #
81 # This file is part of MooX-Attributes-Shadow
82 #
83 # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
84 #
85 # This is free software, licensed under:
86 #
87 # The GNU General Public License, Version 3, June 2007
88 #
89  
90 __END__
« Shadow.pm ↑ Summary