blib/lib/JSON/SchemaValidator/Pointer.pm

filter: Statementstmt 100% 26 / 26 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 92.1% 35 / 38 CC 5 SCAR 11.8
CC
5
Cov
94%
pointer
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« blib/lib/JSON/SchemaValidator.pm ↑ Summary blib/lib/JSON/SchemaValidator/Result.pm »
1 package JSON::SchemaValidator::Pointer;
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 4 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our @EXPORT_OK = qw(pointer);
8  
9 4 ▶use URI::Escape qw(uri_unescape);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub pointer {
12 8 ▶ my ($json, $pointer) = @_;
Subroutine pointer: called CC=5 SCAR=16.2
Pod undocumented
13  
14 8 ▶ return unless $pointer =~ m/^#/;
Branch: 1 branch
BranchTrueFalseTotal
unless $pointer =~ /^#/ 0 8 8
15  
16 8 $pointer = uri_unescape($pointer);
17  
18 8 $pointer =~ s{^#/?}{};
19  
20 8 my $top = $json;
21 8 foreach my $part (split m{/}, $pointer) {
22 10 $part =~ s{\~1}{\/}g;
23 10 $part =~ s{\~0}{\~}g;
24  
25 10 ▶ if (ref $top eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $top eq 'HASH') { } 9 1 10
elsif (ref $top eq 'ARRAY') { } 1 0 1
26 9 $top = $top->{$part};
27 }
28 elsif (ref $top eq 'ARRAY') {
29 1 $top = $top->[$part];
30 }
31 }
32  
33 8 return $top;
34 }
35  
36 4 1;
« blib/lib/JSON/SchemaValidator.pm ↑ Summary blib/lib/JSON/SchemaValidator/Result.pm »