Print/Statement.pm

filter: Statementstmt 100% 39 / 39 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 95.0% 57 / 60 CC 6 SCAR 11.5
CC
6
Cov
96%
print
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« Print.pm ↑ Summary Print/Form.pm »
1 package Wikibase::Datatype::Print::Statement;
2  
3 25 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 25 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 25 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 25 ▶use Wikibase::Datatype::Print::Reference;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 25 ▶use Wikibase::Datatype::Print::Snak;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 25 ▶use Wikibase::Datatype::Print::Utils qw(defaults print_references);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 25 Readonly::Array our @EXPORT_OK => qw(print);
14  
15 25 our $VERSION = 0.21;
16  
17 34 ▶sub print {
Subroutine print: called CC=6 SCAR=18.0
Pod documented
18 34 my ($obj, $opts_hr) = @_;
19  
20 34 $opts_hr = defaults($obj, $opts_hr);
21  
22 34 ▶ if (! $obj->isa('Wikibase::Datatype::Statement')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::Statement")) 1 33 34
23 1 err "Object isn't 'Wikibase::Datatype::Statement'.";
24 }
25  
26 33 my $text_rank = $opts_hr->{'texts'}->{'rank_'.$obj->rank};
27 33 my @ret = (
28 Wikibase::Datatype::Print::Snak::print($obj->snak, $opts_hr).' ('.$text_rank.')',
29 );
30 33 foreach my $property_snak (@{$obj->property_snaks}) {
31 8 push @ret, ' '.Wikibase::Datatype::Print::Snak::print($property_snak, $opts_hr);
32 }
33  
34 # References.
35 33 ▶ if (! exists $opts_hr->{'no_print_references'} || ! $opts_hr->{'no_print_references'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $opts_hr->{"no_print_references"} and $opts_hr->{"no_print_references"}) 32 1 33
Condition66%2/3
exists $opts_hr->{"no_print_references"} and $opts_hr->{"no_print_references"}
!ll&&!rl&&r
3201
MC/DC50%1/2
exists $opts_hr->{"no_print_references"} and $opts_hr->{"no_print_references"}
exists $opts_hr->{"no_print_references"} $opts_hr->{"no_print_references"}
Truth table66%2/3
A and B
A= exists $opts_hr->{"no_print_references"}B= $opts_hr->{"no_print_references"}
ABresult
0X0
100
111
36 32 push @ret, print_references($obj, $opts_hr,
37 \&Wikibase::Datatype::Print::Reference::print);
38 }
39  
40 33 ▶ return wantarray ? @ret : (join "\n", @ret);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 33 0 33
41 }
42  
43 25 1;
44  
45 __END__
« Print.pm ↑ Summary Print/Form.pm »