| 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'} || '#'
MC/DC100%1/1
$params{'root'} || '#'
$params{'root'}
Truth table100%2/2
A
A= $params{'root'}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
$self->{"root"} and $self->{"root"} ne "#"
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 "#"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||