| 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
| |||||||||||||||||||||||||||||
| 19 | 1 | err "Object doesn't exist."; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | 23 | ▶ | if (! $obj->isa('Wikibase::Datatype::Value::String')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
not exists $struct_hr->{"type"} or $struct_hr->{"type"} ne "string"
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"
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||