Struct/Value/Sense.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 6 / 6 Conditioncond 83.3% 15 / 18 MC/DCmcdc 57.1% 4 / 7 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 91.8% 68 / 74 CC 10 SCAR 15.5
CC
10
Cov
95%
struct2obj
8.1
obj2struct
3.0
BEGIN
1.0
CRAP 4.7
« Struct/Form.pm ↑ Summary Struct/Value/Item.pm »
1 package Wikibase::Datatype::Struct::Value::Sense;
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::Sense;
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::Sense')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::Value::Sense")) 1 2 3
22 1 err "Object isn't 'Wikibase::Datatype::Value::Sense'.";
23 }
24  
25 2 my $struct_hr = {
26 'value' => {
27 'entity-type' => $obj->type,
28 'id' => $obj->value,
29 },
30 'type' => 'wikibase-entityid',
31 };
32  
33 2 return $struct_hr;
34 }
35  
36 6 ▶sub struct2obj {
Subroutine struct2obj: called CC=8 SCAR=20.9
Pod documented
37 6 my $struct_hr = shift;
38  
39 6 ▶ 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 "sense") 4 2 6
Condition83%15/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 "sense"
l!l&&r!l&&!r
312
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
303
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
303
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
213
not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid"
l!l&&r!l&&!r
114
exists $struct_hr->{'type'} && defined $struct_hr->{'type'}
!ll&&!rl&&r
105
MC/DC57%4/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 "sense"
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 "sense"
Truth table62%5/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 "sense"
ABCDEFGresult
0XXXXXX1
10XXXXX1
111XXXX1
1101XXX1
11001XX1
110001X1
11000011
11000000
40 || ! defined $struct_hr->{'type'}
41 || $struct_hr->{'type'} ne 'wikibase-entityid'
42 || ! exists $struct_hr->{'value'}
43 || ! exists $struct_hr->{'value'}->{'entity-type'}
44 || ! defined $struct_hr->{'value'}->{'entity-type'}
45 || $struct_hr->{'value'}->{'entity-type'} ne 'sense') {
46  
47 4 err "Structure isn't for 'sense' datatype.";
48 }
49  
50 my $obj = Wikibase::Datatype::Value::Sense->new(
51 2 'value' => $struct_hr->{'value'}->{'id'},
52 );
53  
54 2 return $obj;
55 }
56  
57 54 1;
58  
59 __END__
« Struct/Form.pm ↑ Summary Struct/Value/Item.pm »