Struct/Value/Monolingual.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 6 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 54 / 54 CC 5 SCAR 6.9
CC
5
Cov
100%
obj2struct
3.0
struct2obj
3.0
BEGIN
1.0
CRAP 2.0
« Struct/Reference.pm ↑ Summary Struct/Language.pm »
1 package Wikibase::Datatype::Struct::Value::Monolingual;
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::Monolingual;
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::Monolingual')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::Value::Monolingual")) 1 2 3
22 1 err "Object isn't 'Wikibase::Datatype::Value::Monolingual'.";
23 }
24  
25 2 my $struct_hr = {
26 'value' => {
27 'language' => $obj->language,
28 'text' => $obj->value,
29 },
30 'type' => 'monolingualtext',
31 };
32  
33 2 return $struct_hr;
34 }
35  
36 4 ▶sub struct2obj {
Subroutine struct2obj: called CC=3 SCAR=11.0
Pod documented
37 4 my $struct_hr = shift;
38  
39 4 ▶ if (! exists $struct_hr->{'type'}
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $struct_hr->{"type"} or $struct_hr->{"type"} ne "monolingualtext") 2 2 4
Condition100%3/3
not exists $struct_hr->{"type"} or $struct_hr->{"type"} ne "monolingualtext"
l!l&&r!l&&!r
112
MC/DC100%2/2
not exists $struct_hr->{"type"} or $struct_hr->{"type"} ne "monolingualtext"
not exists $struct_hr->{"type"} $struct_hr->{"type"} ne "monolingualtext"
Truth table100%3/3
not(A) or B
A= not exists $struct_hr->{"type"}B= $struct_hr->{"type"} ne "monolingualtext"
ABresult
1X1
011
000
40 || $struct_hr->{'type'} ne 'monolingualtext') {
41  
42 2 err "Structure isn't for 'monolingualtext' datatype.";
43 }
44  
45 my $obj = Wikibase::Datatype::Value::Monolingual->new(
46 'language' => $struct_hr->{'value'}->{'language'},
47 2 'value' => $struct_hr->{'value'}->{'text'},
48 );
49  
50 2 return $obj;
51 }
52  
53 54 1;
54  
55 __END__
« Struct/Reference.pm ↑ Summary Struct/Language.pm »