Struct/Value/String.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 88.8% 48 / 54 CC 5 SCAR 7.6
CC
5
Cov
90%
struct2obj
3.6
obj2struct
3.0
BEGIN
1.0
CRAP 2.1
« Struct/Value/Time.pm ↑ Summary Struct/Reference.pm »
1 package Wikibase::Datatype::Struct::Value::String;
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::String;
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 24 ▶sub obj2struct {
Subroutine obj2struct: called CC=3 SCAR=11.0
Pod documented
16 24 my $obj = shift;
17  
18 24 ▶ if (! defined $obj) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $obj) 1 23 24
19 1 err "Object doesn't exist.";
20 }
21 23 ▶ if (! $obj->isa('Wikibase::Datatype::Value::String')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::Value::String")) 1 22 23
22 1 err "Object isn't 'Wikibase::Datatype::Value::String'.";
23 }
24  
25 22 my $struct_hr = {
26 'type' => 'string',
27 'value' => $obj->value,
28 };
29  
30 22 return $struct_hr;
31 }
32  
33 22 ▶sub struct2obj {
Subroutine struct2obj: called CC=3 SCAR=12.7
Pod documented
34 22 my $struct_hr = shift;
35  
36 22 ▶ if (! exists $struct_hr->{'type'}
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $struct_hr->{"type"} or $struct_hr->{"type"} ne "string") 0 22 22
Condition33%1/3
not exists $struct_hr->{"type"} or $struct_hr->{"type"} ne "string"
l!l&&r!l&&!r
0022
MC/DC0%0/2
not exists $struct_hr->{"type"} or $struct_hr->{"type"} ne "string"
not exists $struct_hr->{"type"} $struct_hr->{"type"} ne "string"
Truth table33%1/3
not(A) or B
A= not exists $struct_hr->{"type"}B= $struct_hr->{"type"} ne "string"
ABresult
1X1
011
000
37 || $struct_hr->{'type'} ne 'string') {
38  
39 0 err "Structure isn't for 'string' datatype.";
40 }
41  
42 my $obj = Wikibase::Datatype::Value::String->new(
43 22 'value' => $struct_hr->{'value'},
44 );
45  
46 22 return $obj;
47 }
48  
49 54 1;
50  
51 __END__
« Struct/Value/Time.pm ↑ Summary Struct/Reference.pm »