Struct/Value/Property.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 6 / 6 Conditioncond 100% 18 / 18 MC/DCmcdc 100% 7 / 7 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 76 / 76 CC 10 SCAR 15.4
CC
10
Cov
100%
struct2obj
8.0
obj2struct
3.0
BEGIN
1.0
CRAP 4.6
« Struct/Value/Lexeme.pm ↑ Summary Struct/MediainfoStatement.pm »
1 package Wikibase::Datatype::Struct::Value::Property;
2  
3 54 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 54 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 54 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 54 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 54 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 54 ▶use Wikibase::Datatype::Value::Property;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 54 Readonly::Array our @EXPORT_OK => qw(obj2struct struct2obj);
12  
13 54 our $VERSION = 0.15;
14  
15 4 ▶sub obj2struct {
Subroutine obj2struct: called CC=3 SCAR=11.0
Pod documented
16 4 my $obj = shift;
17  
18 4 ▶ if (! defined $obj) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $obj) 1 3 4
19 1 err "Object doesn't exist.";
20 }
21 3 ▶ if (! $obj->isa('Wikibase::Datatype::Value::Property')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::Value::Property")) 1 2 3
22 1 err "Object isn't 'Wikibase::Datatype::Value::Property'.";
23 }
24  
25 2 my $numeric_id = $obj->value;
26 2 $numeric_id =~ s/^P//ms;
27 2 my $struct_hr = {
28 'value' => {
29 'entity-type' => $obj->type,
30 'id' => $obj->value,
31 'numeric-id' => $numeric_id,
32 },
33 'type' => 'wikibase-entityid',
34 };
35  
36 2 return $struct_hr;
37 }
38  
39 9 ▶sub struct2obj {
Subroutine struct2obj: called CC=8 SCAR=20.8
Pod documented
40 9 my $struct_hr = shift;
41  
42 9 ▶ if (! exists $struct_hr->{'type'}
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid" or not exists $struct_hr->{"value"} or not exists $struct_hr->{"value"}{"entity-type"} or not defined $struct_hr->{"value"}{"entity-type"} or $struct_hr->{"value"}{"entity-type"} ne "property") 7 2 9
Condition100%18/18
not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid" or not exists $struct_hr->{"value"} or not exists $struct_hr->{"value"}{"entity-type"} or not defined $struct_hr->{"value"}{"entity-type"} or $struct_hr->{"value"}{"entity-type"} ne "property"
l!l&&r!l&&!r
612
not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid" or not exists $struct_hr->{"value"} or not exists $struct_hr->{"value"}{"entity-type"} or not defined $struct_hr->{"value"}{"entity-type"}
l!l&&r!l&&!r
513
not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid" or not exists $struct_hr->{"value"} or not exists $struct_hr->{"value"}{"entity-type"}
l!l&&r!l&&!r
414
not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid" or not exists $struct_hr->{"value"}
l!l&&r!l&&!r
315
not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid"
l!l&&r!l&&!r
216
exists $struct_hr->{'type'} && defined $struct_hr->{'type'}
!ll&&!rl&&r
117
MC/DC100%7/7
not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid" or not exists $struct_hr->{"value"} or not exists $struct_hr->{"value"}{"entity-type"} or not defined $struct_hr->{"value"}{"entity-type"} or $struct_hr->{"value"}{"entity-type"} ne "property"
exists $struct_hr->{'type'} defined $struct_hr->{'type'} $struct_hr->{"type"} ne "wikibase-entityid" not exists $struct_hr->{"value"} not exists $struct_hr->{"value"}{"entity-type"} not defined $struct_hr->{"value"}{"entity-type"} $struct_hr->{"value"}{"entity-type"} ne "property"
Truth table100%8/8
not(A && B) or C or not(D) or not(E) or not(F) or G
A= exists $struct_hr->{'type'}B= defined $struct_hr->{'type'}C= $struct_hr->{"type"} ne "wikibase-entityid"D= not exists $struct_hr->{"value"}E= not exists $struct_hr->{"value"}{"entity-type"}F= not defined $struct_hr->{"value"}{"entity-type"}G= $struct_hr->{"value"}{"entity-type"} ne "property"
ABCDEFGresult
0XXXXXX1
10XXXXX1
111XXXX1
1101XXX1
11001XX1
110001X1
11000011
11000000
43 || ! defined $struct_hr->{'type'}
44 || $struct_hr->{'type'} ne 'wikibase-entityid'
45 || ! exists $struct_hr->{'value'}
46 || ! exists $struct_hr->{'value'}->{'entity-type'}
47 || ! defined $struct_hr->{'value'}->{'entity-type'}
48 || $struct_hr->{'value'}->{'entity-type'} ne 'property') {
49  
50 7 err "Structure isn't for 'property' datatype.";
51 }
52  
53 my $obj = Wikibase::Datatype::Value::Property->new(
54 2 'value' => $struct_hr->{'value'}->{'id'},
55 );
56  
57 2 return $obj;
58 }
59  
60 54 1;
61  
62 __END__
« Struct/Value/Lexeme.pm ↑ Summary Struct/MediainfoStatement.pm »