Print/MediainfoSnak.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 91.6% 11 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 96.7% 60 / 62 CC 7 SCAR 13.9
CC
7
Cov
96%
print
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« Print/Snak.pm ↑ Summary Print/Value/Lexeme.pm »
1 package Wikibase::Datatype::Print::MediainfoSnak;
2  
3 12 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use Wikibase::Datatype::Print::Utils qw(defaults);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use Wikibase::Datatype::Print::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 12 Readonly::Array our @EXPORT_OK => qw(print);
13  
14 12 our $VERSION = 0.21;
15  
16 10 ▶sub print {
Subroutine print: called CC=7 SCAR=19.5
Pod documented
17 10 my ($obj, $opts_hr) = @_;
18  
19 10 $opts_hr = defaults($obj, $opts_hr);
20  
21 10 ▶ if (! $obj->isa('Wikibase::Datatype::MediainfoSnak')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::MediainfoSnak")) 1 9 10
22 1 err "Object isn't 'Wikibase::Datatype::MediainfoSnak'.";
23 }
24  
25 9 my $property_name = '';
26 9 ▶ if (exists $opts_hr->{'cache'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts_hr->{"cache"}) 1 8 9
27 1 $property_name = $opts_hr->{'cache'}->get('label', $obj->property);
28 1 ▶ if (defined $property_name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $property_name) { } 1 0 1
29 1 $property_name = " ($property_name)";
30 } else {
31 0 $property_name = '';
32 }
33 }
34  
35 9 my $ret = $obj->property.$property_name.': ';
36 9 ▶ if ($obj->snaktype eq 'value') {
Branch: 3 branches
BranchTrueFalseTotal
if ($obj->snaktype eq 'value') { } 6 3 9
elsif ($obj->snaktype eq 'novalue') { } 1 2 3
elsif ($obj->snaktype eq 'somevalue') { } 1 1 2
37 6 $ret .= Wikibase::Datatype::Print::Value::print($obj->datavalue, $opts_hr);
38 } elsif ($obj->snaktype eq 'novalue') {
39 1 $ret .= $opts_hr->{'texts'}->{'value_no'};
40 } elsif ($obj->snaktype eq 'somevalue') {
41 1 $ret .= $opts_hr->{'texts'}->{'value_unknown'};
42 } else {
43 1 err 'Bad snaktype.',
44 'snaktype', $obj->snaktype,
45 ;
46 }
47  
48 8 return $ret;
49 }
50  
51 12 1;
52  
53 __END__
« Print/Snak.pm ↑ Summary Print/Value/Lexeme.pm »