lib/HTML/FormFu/Role/CustomRoles.pm

filter: Statementstmt 91.1% 31 / 34 Branchbran 30.0% 3 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 68.8% 42 / 61 CC 9 SCAR 22.8
CC
9
Cov
72%
roles
14.7
BEGIN
1.0
BEGIN
1.0
CRAP 9.8
« lib/HTML/FormFu/Constraint/Equal.pm ↑ Summary lib/HTML/FormFu/Element/Select.pm »
1 441 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Role::CustomRoles;
4 # ABSTRACT: add custom roles
5 441 $HTML::FormFu::Role::CustomRoles::VERSION = '2.09';
6 441 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 441 ▶use Moose::Util qw( ensure_all_roles );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 441 ▶use List::Util 1.45 qw( uniq );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 has _roles => (
12 is => 'rw',
13 3 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
14 441 lazy => 1,
15 isa => 'ArrayRef',
16 );
17  
18 3 ▶sub roles {
Subroutine roles: called CC=9 SCAR=26.8
Pod undocumented
19 3 my $self = shift;
20  
21 3 my @roles = @{ $self->_roles };
22 3 my @new;
23  
24 3 ▶ if ( 1 == @_ && 'ARRAY' eq ref $_[0] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (1 == @_ and 'ARRAY' eq ref $_[0]) { } 3 0 3
elsif (@_) { } 0 0 0
Condition33%1/3
1 == @_ and "ARRAY" eq ref $_[0]
!ll&&!rl&&r
003
MC/DC0%0/2
1 == @_ and "ARRAY" eq ref $_[0]
1 == @_ "ARRAY" eq ref $_[0]
Truth table33%1/3
A and B
A= 1 == @_B= "ARRAY" eq ref $_[0]
ABresult
0X0
100
111
25 3 @new = @{ $_[0] };
26 }
27 elsif (@_) {
28 0 @new = @_;
29 }
30  
31 3 ▶ if (@new) {
Branch: 1 branch
BranchTrueFalseTotal
if (@new) 3 0 3
32 3 for my $role (@new) {
33 3 ▶ if ( !ref($role) && $role =~ s/^\+// ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $role and $role =~ s/^\+//) { } 3 0 3
elsif (not ref $role) { } 0 0 0
Condition33%1/3
not ref $role and $role =~ s/^\+//
!ll&&!rl&&r
003
MC/DC0%0/2
not ref $role and $role =~ s/^\+//
not ref $role $role =~ s/^\+//
Truth table33%1/3
not(A) and B
A= not ref $roleB= $role =~ s/^\+//
ABresult
0X0
100
111
34 3 push @roles, $role;
35 }
36 elsif ( !ref $role ) {
37 0 push @roles, "HTML::FormFu::Role::$role";
38 }
39 else {
40 0 push @roles, $role;
41 }
42 }
43  
44 3 @roles = uniq @roles;
45  
46 3 ensure_all_roles( $self, @roles );
47  
48 3 $self->_roles( \@roles );
49 }
50  
51 3 return [@roles];
52 }
53  
54 441 1;
55  
56 __END__
« lib/HTML/FormFu/Constraint/Equal.pm ↑ Summary lib/HTML/FormFu/Element/Select.pm »