Struct/Reference.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 53 / 53 CC 4 SCAR 6.9
CC
4
Cov
100%
obj2struct
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Struct/Value/String.pm ↑ Summary Struct/Value/Monolingual.pm »
1 package Wikibase::Datatype::Struct::Reference;
2  
3 38 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 38 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 38 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 38 ▶use Wikibase::Datatype::Reference;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 38 ▶use Wikibase::Datatype::Struct::Utils qw(obj_array_ref2struct struct2snaks_array_ref);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 38 Readonly::Array our @EXPORT_OK => qw(obj2struct struct2obj);
13  
14 38 our $VERSION = 0.15;
15  
16 9 ▶sub obj2struct {
Subroutine obj2struct: called CC=4 SCAR=13.9
Pod documented
17 9 my ($obj, $base_uri) = @_;
18  
19 9 ▶ if (! defined $obj) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $obj) 1 8 9
20 1 err "Object doesn't exist.";
21 }
22 8 ▶ if (! $obj->isa('Wikibase::Datatype::Reference')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::Reference")) 1 7 8
23 1 err "Object isn't 'Wikibase::Datatype::Reference'.";
24 }
25 7 ▶ if (! defined $base_uri) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $base_uri) 1 6 7
26 1 err 'Base URI is required.';
27 }
28  
29 6 my $struct_hr = obj_array_ref2struct($obj->snaks, 'snaks', $base_uri);
30  
31 6 return $struct_hr;
32 }
33  
34 8 ▶sub struct2obj {
Subroutine struct2obj: called CC=1 SCAR=0.0
Pod documented
35 8 my $struct_hr = shift;
36  
37 8 my $obj = Wikibase::Datatype::Reference->new(
38 'snaks' => struct2snaks_array_ref($struct_hr, 'snaks'),
39 );
40  
41 8 return $obj;
42 }
43  
44 38 1;
45  
46 __END__
« Struct/Value/String.pm ↑ Summary Struct/Value/Monolingual.pm »