| 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
Condition100%3/3
ref $params[0] eq "HASH" and ref $params[0]{"param"} eq "ARRAY"
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"
| |||||||||||||||||||||||||||||
| 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])
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])
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 40 | 2 | foreach my $param_name ( keys %{$name} ) { | |||||||||||||||||||||||||||
| 41 | 6 | ▶ | if (defined $name->{$param_name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 66 | 1 | my %list = (); | |||||||||||||||||||||||||||
| 67 | 1 | foreach my $param_name ( @{$name} ) { | |||||||||||||||||||||||||||
| 68 | 1 | ▶ | next if ( not exists $self->{PARAMS}{$param_name} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 86 | 140 | ▶ | return ( ref $ref_or_item eq 'ARRAY' ) ? @{$ref_or_item} : ($ref_or_item); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 53 | 1; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||