Signatures/Param/Named.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 6 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 100% 46 / 46 CC 5 SCAR 8.2
CC
5
Cov
100%
__ANON__
4.0
_stringify_required
2.0
BEGIN
1.0
CRAP 2.3
« Signatures/Sig.pm ↑ Summary Signatures/Param.pm »
1 package Parse::Method::Signatures::Param::Named;
2  
3 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use MooseX::Types::Moose qw/Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 has label => (
9 is => 'ro',
10 isa => Str,
11 lazy_build => 1,
12 );
13  
14 sub _label_from_variable_name {
15 72 ▶ my ($self) = @_;
Subroutine _label_from_variable_name: called CC=1 SCAR=0.0
16 # strip sigil
17 72 return substr($self->variable_name, 1);
18 }
19  
20 sub _build_label {
21 35 ▶ my ($self) = @_;
Subroutine _build_label: called CC=1 SCAR=0.0
22 35 return $self->_label_from_variable_name;
23 }
24  
25 sub _stringify_required {
26 42 ▶ my ($self) = @_;
Subroutine _stringify_required: called CC=2 SCAR=6.9
27 42 ▶ return $self->required ? q{!} : q{};
Branch: 1 branch
BranchTrueFalseTotal
$self->required ? : 5 37 42
28 }
29  
30 around _stringify_variable_name => sub {
31 42 ▶ my $orig = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
32 42 my ($self) = @_;
33 42 my $ret = q{:};
34 42 my ($before, $after) = (q{}) x 2;
35  
36 42 ▶ my $implicit_label = $self->_label_from_variable_name if $self->can('variable_name');
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("variable_name") 37 5 42
37  
38 42 ▶ if (!$implicit_label || $self->label ne $implicit_label) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $implicit_label or $self->label ne $implicit_label) 7 35 42
Condition100%3/3
not $implicit_label or $self->label ne $implicit_label
l!l&&r!l&&!r
5235
MC/DC100%2/2
not $implicit_label or $self->label ne $implicit_label
not $implicit_label $self->label ne $implicit_label
Truth table100%3/3
not(A) or B
A= not $implicit_labelB= $self->label ne $implicit_label
ABresult
1X1
011
000
39 7 $before = $self->label . q{(};
40 7 $after = q{)};
41 }
42  
43 42 $ret .= $before . $orig->(@_) . $after;
44  
45 42 return $ret;
46 3 };
47  
48 3 1;
« Signatures/Sig.pm ↑ Summary Signatures/Param.pm »