JSV/Result.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 80.0% 8 / 10 Conditioncond 80.0% 4 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 5 totaltotal 84.9% 62 / 73 CC 8 SCAR 9.0
CC
8
Cov
93%
to_boolean
4.0
get_error
4.0
new
2.0
CRAP 2.5
« JSV/Keyword/Draft4/Format.pm ↑ Summary Test/JSV/Suite.pm »
1 package JSV::Result;
2  
3 49 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 49 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 use overload
6 49 ▶ 'bool' => \&to_boolean,
Subroutine BEGIN: called CC=1 SCAR=0.0
7 49 'eq' => \=
8  
9 49 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 49 ▶use Hash::MultiValue;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 49 ▶use Class::Accessor::Lite (
Subroutine BEGIN: called CC=1 SCAR=0.0
12 49 new => 0,
13 rw => [qw/instance error errors/]
14 49 );
15  
16 2011 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
17 2011 my $class = shift;
18 2011 ▶ my $args = ref $_[0] ? $_[0] : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 2011 2011
19  
20 2011 %$args = (
21 errors => [],
22 error => "",
23 %$args,
24 );
25  
26 2011 bless $args => $class;
27 }
28  
29  
30 757 ▶sub equals {
Subroutine equals: called CC=1 SCAR=0.0
Pod undocumented
31 757 $_[0]->to_boolean == $_[1];
32 }
33  
34 779 ▶sub to_boolean {
Subroutine to_boolean: called CC=4 SCAR=13.9
Pod undocumented
35 779 my $self = shift;
36 779 ▶ return (($self->errors && scalar @{ $self->errors }) || $self->error) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->errors && scalar @{$self->errors;} || $self->error ? : 359 420 779
Condition80%4/5
$self->errors and scalar @{$self->errors;} or $self->error
l!l&&r!l&&!r
3581420
$self->errors and scalar @{$self->errors;}
!ll
0779
MC/DC0%0/2
$self->errors and scalar @{$self->errors;} or $self->error
$self->errors $self->error
Truth table33%1/3
A or B
A= $self->errorsB= $self->error
ABresult
1X1
011
000
37 }
38  
39 16 ▶sub get_error {
Subroutine get_error: called CC=4 SCAR=13.9
Pod undocumented
40 16 my ($self, $pointer) = @_;
41  
42 16 ▶ if ( $self->error ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->error) { } 1 15 16
elsif ($self->errors) { } 15 0 15
43 1 return $self->error;
44 }
45 elsif ( $self->errors ) {
46 15 ▶ if ( $pointer ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pointer) { } 1 14 15
47 1 return grep { $_->{pointer} eq $pointer } @{ $self->errors };
48 }
49 else {
50 14 return @{ $self->errors };
51 }
52 }
53 }
54  
55 1 ▶sub get_error_map {
Subroutine get_error_map: called CC=1 SCAR=0.2
Pod undocumented
56 1 my $self = shift;
57 0 return Hash::MultiValue->new(map { $_->{pointer} => $_ } @{ $self->errors });
58 }
59  
60 49 1;
« JSV/Keyword/Draft4/Format.pm ↑ Summary Test/JSV/Suite.pm »