blib/lib/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
« blib/lib/JSV/Keyword/Draft4/Format.pm ↑ Summary blib/lib/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,
7 49 ▶ 'eq' => \=
Subroutine BEGIN: called CC=1 SCAR=0.0
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 use Class::Accessor::Lite (
12 49 new => 0,
13 rw => [qw/instance error errors/]
14 49 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 sub new {
17 1784 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
18 1784 ▶ my $args = ref $_[0] ? $_[0] : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 1784 1784
19  
20 1784 %$args = (
21 errors => [],
22 error => "",
23 %$args,
24 );
25  
26 1784 bless $args => $class;
27 }
28  
29  
30 sub equals {
31 672 ▶ $_[0]->to_boolean == $_[1];
Subroutine equals: called CC=1 SCAR=0.0
Pod undocumented
32 }
33  
34 sub to_boolean {
35 692 ▶ my $self = shift;
Subroutine to_boolean: called CC=4 SCAR=13.9
Pod undocumented
36 692 ▶ return (($self->errors && scalar @{ $self->errors }) || $self->error) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->errors && scalar @{$self->errors;} || $self->error ? : 314 378 692
Condition80%4/5
$self->errors and scalar @{$self->errors;} or $self->error
l!l&&r!l&&!r
3131378
$self->errors and scalar @{$self->errors;}
!ll
0692
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 sub get_error {
40 14 ▶ my ($self, $pointer) = @_;
Subroutine get_error: called CC=4 SCAR=13.9
Pod undocumented
41  
42 14 ▶ if ( $self->error ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->error) { } 1 13 14
elsif ($self->errors) { } 13 0 13
43 1 return $self->error;
44 }
45 elsif ( $self->errors ) {
46 13 ▶ if ( $pointer ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pointer) { } 1 12 13
47 1 return grep { $_->{pointer} eq $pointer } @{ $self->errors };
48 }
49 else {
50 12 return @{ $self->errors };
51 }
52 }
53 }
54  
55 sub get_error_map {
56 1 ▶ my $self = shift;
Subroutine get_error_map: called CC=1 SCAR=0.2
Pod undocumented
57 1 return Hash::MultiValue->new(map { $_->{pointer} => $_ } @{ $self->errors });
58 }
59  
60 49 1;
« blib/lib/JSV/Keyword/Draft4/Format.pm ↑ Summary blib/lib/Test/JSV/Suite.pm »