Kavorka/TraitFor/Sub/override.pm

filter: Statementstmt 100% 31 / 31 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 93.6% 44 / 47 CC 5 SCAR 10.1
CC
5
Cov
92%
__ANON__
5.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
« Kavorka/ReturnType.pm ↑ Summary Kavorka/Sub/Fun.pm »
1 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Kavorka::TraitFor::Sub::override;
6  
7 1 our $AUTHORITY = 'cpan:TOBYINK';
8 1 our $VERSION = '0.039';
9  
10 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Types::Standard qw(Any);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 before install_sub => sub
16 3 ▶{
Subroutine __ANON__: called CC=5 SCAR=16.5
17 3 my $self = shift;
18
19 3 ▶ croak("The 'override' trait cannot be applied to lexical methods")
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_lexical 0 3 3
20 if $self->is_lexical;
21
22 3 ▶ croak("The 'override' trait cannot be applied to anonymous methods")
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_anonymous 0 3 3
23 if $self->is_anonymous;
24
25 3 ▶ croak("The 'override' trait may only be applied to methods")
Branch: 1 branch
BranchTrueFalseTotal
if $self->invocation_style ne "method" 0 3 3
26 if $self->invocation_style ne 'method';
27
28 3 my ($pkg, $name) = ($self->qualified_name =~ /^(.+)::(\w+)$/);
29 3 ▶ return if $pkg->can($name);
Branch: 1 branch
BranchTrueFalseTotal
if $pkg->can($name) 2 1 3
30
31 1 croak("Method '$name' does not exist in inheritance hierarchy; cannot override");
32 1 };
33  
34 1 1;
« Kavorka/ReturnType.pm ↑ Summary Kavorka/Sub/Fun.pm »