JSV/Keyword/Draft4/Dependencies.pm

filter: Statementstmt 100% 33 / 33 Branchbran 87.5% 7 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 92.4% 49 / 53 CC 7 SCAR 13.9
CC
7
Cov
95%
validate
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« JSV/Util/Type.pm ↑ Summary JSV/Keyword/Draft4/AnyOf.pm »
1 package JSV::Keyword::Draft4::Dependencies;
2  
3 47 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 47 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 47 ▶use parent qw(JSV::Keyword);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 47 ▶use JSV::Keyword qw(:constants);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 47 ▶use JSV::Util::Type qw(escape_json_pointer);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 47 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub instance_type() { INSTANCE_TYPE_OBJECT(); }
12 sub keyword() { "dependencies" }
13 sub keyword_priority() { 10; }
14  
15 54 ▶sub validate {
Subroutine validate: called CC=7 SCAR=19.5
Pod undocumented
16 54 my ($class, $context, $schema, $instance) = @_;
17  
18 54 my $dependencies = $class->keyword_value($schema);
19 54 ▶ $dependencies ||= {};
Condition50%1/2
$dependencies ||= {}
l!l
540
MC/DC0%0/1
$dependencies ||= {}
$dependencies
Truth table50%1/2
A
A= $dependencies
Aresult
11
00
20  
21 54 for my $property (keys %$dependencies) {
22 62 ▶ next unless (exists $instance->{$property});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $instance->{$property} 28 34 62
23  
24 34 local $context->{current_pointer} = $context->{current_pointer} . "/" . escape_json_pointer( $property );
25 local $context->{current_schema_pointer} =
26 34 $context->{current_schema_pointer} . "/" . $class->keyword . "/" . escape_json_pointer( $property );
27  
28 34 ▶ if (ref $dependencies->{$property} eq "ARRAY") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $dependencies->{$property} eq 'ARRAY') { } 21 13 34
elsif (ref $dependencies->{$property} eq 'HASH') { } 13 0 13
29 21 ▶ my $found_against_dependency = first { !exists $instance->{$_} } @{$dependencies->{$property}};
Subroutine __ANON__: called CC=1 SCAR=0.0
30 21 ▶ if ($found_against_dependency) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found_against_dependency) 15 6 21
31 15 $context->log_error(sprintf("%s property has dependency on the %s field", $property, $found_against_dependency));
32 }
33 }
34 elsif (ref $dependencies->{$property} eq "HASH") {
35 13 $context->validate($dependencies->{$property}, $instance);
36 }
37 }
38 }
39  
40 47 1;
« JSV/Util/Type.pm ↑ Summary JSV/Keyword/Draft4/AnyOf.pm »