Workflow/State/AutoApply.pm

filter: Statementstmt 92.1% 35 / 38 Branchbran 56.2% 9 / 16 Conditioncond 44.4% 4 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 71.4% 55 / 77 CC 12 SCAR 16.7
CC
12
Cov
76%
__ANON__
9.2
__ANON__
5.9
__ANON__
2.0
CRAP 5.3
« Workflow/Transition/Validate/Simple.pm ↑ Summary Workflow/State/TransitionHash.pm »
1 #!/usr/bin/perl
2  
3 package Class::Workflow::State::AutoApply;
4 5 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Scalar::Util qw/refaddr/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 has auto_transition => (
10 does => "Class::Workflow::Transition",
11 accessor => "auto_transition",
12 predicate => "has_auto_transition",
13 required => 0,
14 );
15  
16 25 ▶around transitions => sub {
Subroutine __ANON__: called CC=5 SCAR=17.8
17 25 my $next = shift;
18 25 my ( $self, @transitions ) = @_;
19  
20 25 my @ret = $self->$next( @transitions );
21  
22 # if the auto transition was not in ->transitions( @set ) then delete it
23 25 ▶ if ( @transitions and my $auto = $self->auto_transition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@transitions and my $auto = $self->auto_transition) 0 25 25
Condition66%2/3
@transitions and my $auto = $self->auto_transition
!ll&&!rl&&r
2230
MC/DC0%0/2
@transitions and my $auto = $self->auto_transition
@transitions my $auto = $self->auto_transition
Truth table66%2/3
A and B
A= @transitionsB= my $auto = $self->auto_transition
ABresult
0X0
100
111
24 0 ▶ $self->auto_transition(undef) unless grep { $_ == $auto } @transitions;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ == $auto;} @transitions 0 0 0
25 }
26  
27 25 ▶ if ( my $auto = $self->auto_transition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $auto = $self->auto_transition) { } 1 24 25
28 1 return $auto, @ret;
29 } else {
30 24 return @ret;
31 }
32 5 };
33  
34 13 ▶around has_transition => sub {
Subroutine __ANON__: called CC=6 SCAR=22.1
35 13 my $next = shift;
36 13 my ( $self, $transition ) = @_;
37  
38 13 ▶ if ( my $auto = $self->auto_transition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $auto = $self->auto_transition) 2 11 13
39 2 ▶ if ( ref $transition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $transition) { } 2 0 2
40 2 ▶ return 1 if refaddr($auto) == refaddr($transition);
Branch: 1 branch
BranchTrueFalseTotal
if builtin::refaddr($auto) == builtin::refaddr($transition) 2 0 2
41 } else {
42 0 ▶ return 1 if $auto->can("name") and $auto->name eq $transition;
Branch: 1 branch
BranchTrueFalseTotal
if $auto->can("name") and $auto->name eq $transition 0 0 0
Condition0%0/3
$auto->can("name") and $auto->name eq $transition
!ll&&!rl&&r
000
MC/DC0%0/2
$auto->can("name") and $auto->name eq $transition
$auto->can("name") $auto->name eq $transition
Truth table0%0/3
A and B
A= $auto->can("name")B= $auto->name eq $transition
ABresult
0X0
100
111
43 }
44 }
45  
46 11 return $self->$next($transition);
47 5 };
48  
49 11 ▶around accept_instance => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
50 11 my $next = shift;
51 11 my ( $self, $orig_instance, @args ) = @_;
52 11 my $instance = $self->$next( $orig_instance, @args );
53  
54 11 ▶ return $self->apply_auto_transition( $instance, @args ) || $instance;
Condition66%2/3
$self->apply_auto_transition($instance, @args) || $instance
l!l&&r!l&&!r
290
MC/DC0%0/2
$self->apply_auto_transition($instance, @args) || $instance
$self->apply_auto_transition($instance, @args) $instance
Truth table66%2/3
A || B
A= $self->apply_auto_transition($instance, @args)B= $instance
ABresult
1X1
011
000
55 5 };
56  
57 11 ▶sub apply_auto_transition {
Subroutine apply_auto_transition: called CC=2 SCAR=6.9
Pod undocumented
58 11 my ( $self, $instance, @args ) = @_;
59  
60 11 ▶ if ( my $auto_transition = $self->auto_transition ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $auto_transition = $self->auto_transition) 2 9 11
61 2 return $auto_transition->apply( $instance, @args );
62 }
63  
64 9 return;
65 }
66  
67 5 __PACKAGE__;
68  
69 __END__
« Workflow/Transition/Validate/Simple.pm ↑ Summary Workflow/State/TransitionHash.pm »