blib/lib/JSON/SchemaValidator/Result.pm

filter: Statementstmt 95.7% 45 / 47 Branchbran 100% 6 / 6 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 6 totaltotal 85.5% 65 / 76 SCAR 20.8
CC
8
Cov
95%
add_error
5.0
merge
3.0
new
2.0
CRAP 8.0
« blib/lib/JSON/SchemaValidator.pm ↑ Summary blib/lib/JSON/SchemaValidator/Pointer.pm »
1 package JSON::SchemaValidator::Result;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 9 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
10 9 my (%params) = @_;
11  
12 9 my $self = {};
13 9 bless $self, $class;
14  
15 9 $self->{errors} = [];
16 9 ▶ $self->{root} = $params{root} || '#';
Condition100%2/2
$params{'root'} || '#'
l!l
18
MC/DC100%1/1
$params{'root'} || '#'
$params{'root'}
Truth table100%2/2
A
A= $params{'root'}
Aresult
11
00
17  
18 9 return $self;
19 }
20  
21 sub is_success {
22 6 ▶ my $self = shift;
Subroutine is_success: called CC=1 SCAR=0.0
Pod undocumented
23  
24 6 return @{$self->{errors}} == 0;
25 }
26  
27 sub errors {
28 6 ▶ my $self = shift;
Subroutine errors: called CC=1 SCAR=0.0
Pod undocumented
29  
30 6 return $self->{errors};
31 }
32  
33 sub errors_json {
34 0 ▶ my $self = shift;
Subroutine errors_json: not called CC=1 SCAR=6.9
Pod undocumented
35  
36 0 return JSON::encode_json($self->{errors});
37 }
38  
39 sub add_error {
40 6 ▶ my $self = shift;
Subroutine add_error: called CC=5 SCAR=16.1
Pod undocumented
41  
42 6 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 1 5 6
43 1 my ($error) = @_;
44 1 foreach my $suberror (@{$error->errors}) {
45 1 push @{$self->{errors}}, $suberror;
46 }
47 }
48 else {
49 5 my %params = @_;
50  
51 5 my $uri = $params{uri};
52 5 ▶ if ($self->{root} && $self->{root} ne '#') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"root"} and $self->{"root"} ne "#") 1 4 5
Condition66%2/3
$self->{"root"} and $self->{"root"} ne "#"
!ll&&!rl&&r
041
MC/DC50%1/2
$self->{"root"} and $self->{"root"} ne "#"
$self->{"root"} $self->{"root"} ne "#"
Truth table66%2/3
A and B
A= $self->{"root"}B= $self->{"root"} ne "#"
ABresult
0X0
100
111
53 1 $uri =~ s{^#}{$self->{root}};
54 1 $params{uri} = $uri;
55 }
56  
57 5 push @{$self->{errors}}, {%params};
58 }
59  
60 6 return $self;
61 }
62  
63 sub merge {
64 3 ▶ my $self = shift;
Subroutine merge: called CC=3 SCAR=11.0
Pod undocumented
65 3 my ($subresult) = @_;
66  
67 3 ▶ return $self if $subresult->is_success;
Branch: 1 branch
BranchTrueFalseTotal
if $subresult->is_success 1 2 3
68  
69 2 foreach my $suberror (@{$subresult->errors}) {
70 2 push @{$self->{errors}}, $suberror;
71 }
72  
73 2 return $self;
74 }
75  
76 4 1;
« blib/lib/JSON/SchemaValidator.pm ↑ Summary blib/lib/JSON/SchemaValidator/Pointer.pm »