| 1 | package Error::ROP::Imp; | ||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 5 | has value => (is => 'ro', required => 0, default => undef); | |||||||||||||||||||||||||||
| 5 | 5 | has failure => (is => 'ro', required => 0, default => ''); | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | sub is_valid { | ||||||||||||||||||||||||||||
| 8 | 46 | ▶ | return shift->failure eq ''; | ||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub _then_hash { | ||||||||||||||||||||||||||||
| 12 | 13 | ▶ | my ($self, @then_clauses) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_then_hash: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 13 | 13 | my $either = $self; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 13 | my $length = @then_clauses / 2; | |||||||||||||||||||||||||||
| 16 | 13 | ▶ | for(my $i = 0; $i < $length; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 15 | my $err = $then_clauses[2 * $i]; | |||||||||||||||||||||||||||
| 18 | 15 | my $fn = $then_clauses[2 * $i + 1]; | |||||||||||||||||||||||||||
| 19 | 15 | ▶ | if ($either->is_valid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 12 | local $_ = $either->value; | |||||||||||||||||||||||||||
| 21 | 12 | my $res = eval { | |||||||||||||||||||||||||||
| 22 | 12 | $fn->($_); | |||||||||||||||||||||||||||
| 23 | }; | ||||||||||||||||||||||||||||
| 24 | 12 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 3 | ▶ | my $msg = length $err > 0 && $err ne 'undef' ? $err : $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
length $err > 0 and $err ne "undef"
MC/DC100%2/2
length $err > 0 and $err ne "undef"
length $err > 0
$err ne "undef"
Truth table100%3/3
A and B
A= length $err > 0B= $err ne "undef"
| |||||||||||||||||||||||||||||
| 26 | 3 | return Error::ROP::Imp->new(failure => $msg); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 9 | $either = Error::ROP::Imp->new(value => $res); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 10 | return $either; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub _then_list { | ||||||||||||||||||||||||||||
| 36 | 7 | ▶ | my ($self, @then_clauses) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_then_list: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 37 | 7 | my $either = $self; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 7 | my $length = @then_clauses; | |||||||||||||||||||||||||||
| 40 | 7 | ▶ | for(my $i = 0; $i < $length; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 7 | my $fn = $then_clauses[$i]; | |||||||||||||||||||||||||||
| 42 | 7 | ▶ | if ($either->is_valid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 3 | local $_ = $either->value; | |||||||||||||||||||||||||||
| 44 | 3 | my $res = eval { | |||||||||||||||||||||||||||
| 45 | 3 | $fn->($_); | |||||||||||||||||||||||||||
| 46 | }; | ||||||||||||||||||||||||||||
| 47 | 3 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 2 | return Error::ROP::Imp->new(failure => $@); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 1 | $either = Error::ROP::Imp->new(value => $res); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 5 | return $either; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | sub _wrap_call_with_dollar { | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | my $either = shift; | ||||||||||||||||||||||||||
|
Subroutine
_wrap_call_with_dollar: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 59 | 0 | my $fn = shift; | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ($either->is_valid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | local $_ = $either->value; | |||||||||||||||||||||||||||
| 62 | 0 | my $res = eval { | |||||||||||||||||||||||||||
| 63 | 0 | $fn->($_); | |||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | return Error::ROP::Imp->new(failure => $@); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 0 | $either = Error::ROP::Imp->new(value => $res); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub then { | ||||||||||||||||||||||||||||
| 73 | 20 | ▶ | my ($self, @then_clauses) = @_; | ||||||||||||||||||||||||||
|
Subroutine
then: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 20 | ▶ | if((scalar @then_clauses) % 2 == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 13 | $self->_then_hash(@then_clauses); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | else { | ||||||||||||||||||||||||||||
| 79 | 7 | $self->_then_list(@then_clauses); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 5 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 84 | 5 | 1; | |||||||||||||||||||||||||||