Workflow/Base.pm

filter: Statementstmt 96.6% 58 / 60 Branchbran 85.0% 17 / 20 Conditioncond 83.3% 5 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 12 / 12 Podpod 100% 7 / 7 totaltotal 92.6% 101 / 109 CC 16 SCAR 12.9
CC
16
Cov
93%
param
6.0
delete_param
5.1
new
4.0
CRAP 3.6
« Workflow/Config/Perl.pm ↑ Summary Workflow/Config.pm »
1 package Workflow::Base;
2  
3 53 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 53 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 53 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 53 ▶use parent qw( Class::Accessor );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 53 ▶use Log::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 53 $Workflow::Base::VERSION = '2.12';
10  
11 438 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
12 438 my ( $class, @params ) = @_;
13 438 my $self = bless { PARAMS => {} }, $class;
14  
15 438 ▶ if ( ref $params[0] eq 'HASH' && ref $params[0]->{param} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $params[0] eq "HASH" and ref $params[0]{"param"} eq "ARRAY") 23 415 438
Condition100%3/3
ref $params[0] eq "HASH" and ref $params[0]{"param"} eq "ARRAY"
!ll&&!rl&&r
11829723
MC/DC100%2/2
ref $params[0] eq "HASH" and ref $params[0]{"param"} eq "ARRAY"
ref $params[0] eq "HASH" ref $params[0]{"param"} eq "ARRAY"
Truth table100%3/3
A and B
A= ref $params[0] eq "HASH"B= ref $params[0]{"param"} eq "ARRAY"
ABresult
0X0
100
111
16 23 foreach my $declared ( @{ $params[0]->{param} } ) {
17 30 $params[0]->{ $declared->{name} } = $declared->{value};
18 }
19 23 delete $params[0]->{param};
20 }
21 438 $self->init(@params);
22 434 return $self;
23 }
24  
25 1 ▶sub init {return};
Subroutine init: called CC=1 SCAR=0.0
Pod documented
26  
27 2849 ▶sub log {
Subroutine log: called CC=2 SCAR=7.2
Pod documented
28 2849 ▶ return ( $_[0]->{log} ||= Log::Any->get_logger( category => ref $_[0] ) );
Condition66%2/3
$_[0]{"log"} ||= "Log::Any"->get_logger("category", ref $_[0])
l!l&&r!l&&!r
25662830
MC/DC0%0/2
$_[0]{"log"} ||= "Log::Any"->get_logger("category", ref $_[0])
$_[0]{"log"} "Log::Any"->get_logger("category", ref $_[0])
Truth table66%2/3
A ||= B
A= $_[0]{"log"}B= "Log::Any"->get_logger("category", ref $_[0])
ABresult
1X1
011
000
29 }
30  
31 517 ▶sub param {
Subroutine param: called CC=6 SCAR=18.0
Pod documented
32 517 my ( $self, $name, $value ) = @_;
33 517 ▶ unless ( defined $name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 76 441 517
34 76 return { %{ $self->{PARAMS} } };
35 }
36  
37 # Allow multiple parameters to be set at once...
38  
39 441 ▶ if ( ref $name eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $name eq "HASH") 2 439 441
40 2 foreach my $param_name ( keys %{$name} ) {
41 6 ▶ if (defined $name->{$param_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name->{$param_name}) { } 6 0 6
42 6 $self->{PARAMS}{$param_name} = $name->{$param_name};
43 }
44 else {
45 0 delete $self->{PARAMS}->{$param_name};
46 }
47 }
48 2 return { %{ $self->{PARAMS} } };
49 }
50  
51 439 ▶ unless ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 257 182 439
52 257 return $self->{PARAMS}{$name};
53 }
54 182 return $self->{PARAMS}{$name} = $value;
55 }
56  
57 2 ▶sub delete_param {
Subroutine delete_param: called CC=5 SCAR=16.3
Pod documented
58 2 my ( $self, $name ) = @_;
59 2 ▶ unless ( defined $name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 0 2 2
60 0 return undef;
61 }
62  
63 # Allow multiple parameters to be deleted at once...
64  
65 2 ▶ if ( ref $name eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $name eq "ARRAY") 1 1 2
66 1 my %list = ();
67 1 foreach my $param_name ( @{$name} ) {
68 1 ▶ next if ( not exists $self->{PARAMS}{$param_name} );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"PARAMS"}{$param_name} 0 1 1
69 1 $list{$param_name} = $self->{PARAMS}{$param_name};
70 1 delete $self->{PARAMS}{$param_name};
71 }
72 1 return {%list};
73 }
74  
75 1 return delete $self->{PARAMS}{$name};
76 }
77  
78 1 ▶sub clear_params {
Subroutine clear_params: called CC=1 SCAR=0.0
Pod documented
79 1 my ($self) = @_;
80 1 $self->{PARAMS} = {};
81 }
82  
83 277 ▶sub normalize_array {
Subroutine normalize_array: called CC=3 SCAR=11.0
Pod documented
84 277 my ( $self, $ref_or_item ) = @_;
85 277 ▶ return () unless ($ref_or_item);
Branch: 1 branch
BranchTrueFalseTotal
unless $ref_or_item 137 140 277
86 140 ▶ return ( ref $ref_or_item eq 'ARRAY' ) ? @{$ref_or_item} : ($ref_or_item);
Branch: 1 branch
BranchTrueFalseTotal
ref $ref_or_item eq 'ARRAY' ? : 129 11 140
87 }
88  
89 53 1;
90  
91 __END__
« Workflow/Config/Perl.pm ↑ Summary Workflow/Config.pm »