Workflow/Condition/LazyOR.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 100% 45 / 45 CC 4 SCAR 5.9
CC
4
Cov
100%
evaluate
3.0
init
2.0
BEGIN
1.0
CRAP 1.8
« Workflow/Validator.pm ↑ Summary Workflow/Condition/Evaluate.pm »
1 package Workflow::Condition::LazyOR;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '2.12';
8  
9 2 ▶use parent qw( Workflow::Condition );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Workflow::Exception qw( configuration_error );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 __PACKAGE__->mk_accessors('conditions');
13  
14  
15 2 ▶sub init {
Subroutine init: called CC=2 SCAR=6.9
Pod documented
16 2 my ( $self, $params ) = @_;
17 2 $self->SUPER::init( $params );
18  
19 # This is a tricky one. The admin may have configured this by repeating
20 # the param name "condition" or by using unique names (e.g.: "condition1",
21 # "condition2", etc.). We'll need to string these back together as
22 # an array.
23 # Yes, I know. The regex doesn't require the suffix to be numeric.
24 2 my @conditions = ();
25 2 foreach my $key ( sort grep {m/^condition/} keys %{$params} ) {
26 5 push @conditions, $self->normalize_array( $params->{$key} );
27 }
28 2 $self->conditions( [@conditions] );
29 }
30  
31 4 ▶sub evaluate {
Subroutine evaluate: called CC=3 SCAR=11.0
Pod documented
32 4 my ( $self, $wf ) = @_;
33 4 my $conditions = $self->conditions;
34  
35 4 my $total = 0;
36  
37 4 foreach my $cond ( @{$conditions} ) {
38 8 my $result = $self->evaluate_condition( $wf, $cond );
39 8 ▶ if ($result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 2 6 8
40 2 return Workflow::Condition::IsTrue->new("Got match in " . $cond );
41 }
42 }
43 2 return Workflow::Condition::IsFalse->new();
44 }
45  
46 2 1;
47  
48 __END__
« Workflow/Validator.pm ↑ Summary Workflow/Condition/Evaluate.pm »