Struct/Value/Lexeme.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/Item.pm ↑ Summary Struct/Value/Property.pm »
1 package Wikibase::Datatype::Struct::Value::Lexeme;
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::Lexeme;
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 3 ▶sub obj2struct {
Subroutine obj2struct: called CC=3 SCAR=11.0
Pod documented
16 3 my $obj = shift;
17  
18 3 ▶ if (! defined $obj) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $obj) 1 2 3
19 1 err "Object doesn't exist.";
20 }
21 2 ▶ if (! $obj->isa('Wikibase::Datatype::Value::Lexeme')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::Value::Lexeme")) 1 1 2
22 1 err "Object isn't 'Wikibase::Datatype::Value::Lexeme'.";
23 }
24  
25 1 my $numeric_id = $obj->value;
26 1 $numeric_id =~ s/^L//ms;
27 1 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 1 return $struct_hr;
37 }
38  
39 8 ▶sub struct2obj {
Subroutine struct2obj: called CC=8 SCAR=20.8
Pod documented
40 8 my $struct_hr = shift;
41  
42 8 ▶ 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 "lexeme") 7 1 8
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 "lexeme"
l!l&&r!l&&!r
611
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
512
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
413
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
314
not exists $struct_hr->{"type"} && defined $struct_hr->{"type"} or $struct_hr->{"type"} ne "wikibase-entityid"
l!l&&r!l&&!r
215
exists $struct_hr->{'type'} && defined $struct_hr->{'type'}
!ll&&!rl&&r
116
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 "lexeme"
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 "lexeme"
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 "lexeme"
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 'lexeme') {
49  
50 7 err "Structure isn't for 'lexeme' datatype.";
51 }
52  
53 my $obj = Wikibase::Datatype::Value::Lexeme->new(
54 1 'value' => $struct_hr->{'value'}->{'id'},
55 );
56  
57 1 return $obj;
58 }
59  
60 54 1;
61  
62 __END__
« Struct/Value/Item.pm ↑ Summary Struct/Value/Property.pm »