Print/Form.pm

filter: Statementstmt 100% 47 / 47 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 96.9% 64 / 66 CC 6 SCAR 11.0
CC
6
Cov
96%
print
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« Print/Statement.pm ↑ Summary Print/Lexeme.pm »
1 package Wikibase::Datatype::Print::Form;
2  
3 10 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Wikibase::Datatype::Print::Statement;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Wikibase::Datatype::Print::Utils qw(defaults print_statements);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use Wikibase::Datatype::Print::Value::Item;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use Wikibase::Datatype::Print::Value::Monolingual;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 10 Readonly::Array our @EXPORT_OK => qw(print);
15  
16 10 our $VERSION = 0.21;
17  
18 7 ▶sub print {
Subroutine print: called CC=6 SCAR=17.9
Pod documented
19 7 my ($obj, $opts_hr) = @_;
20  
21 7 $opts_hr = defaults($obj, $opts_hr);
22  
23 7 ▶ if (! $obj->isa('Wikibase::Datatype::Form')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->isa("Wikibase::Datatype::Form")) 1 6 7
24 1 err "Object isn't 'Wikibase::Datatype::Form'.";
25 }
26  
27 my @ret = (
28 6 $opts_hr->{'texts'}->{'id'}.': '.$obj->id,
29 );
30  
31 # Representation.
32 # XXX In every time one?
33 6 my ($representation) = @{$obj->representations};
34 6 ▶ if (defined $representation) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $representation) 6 0 6
35 6 push @ret, $opts_hr->{'texts'}->{'representation'}.': '.
36 Wikibase::Datatype::Print::Value::Monolingual::print($representation, $opts_hr);
37 }
38  
39 # Grammatical features
40 6 my @gr_features;
41 6 foreach my $gr_feature (@{$obj->grammatical_features}) {
42 12 push @gr_features,
43 Wikibase::Datatype::Print::Value::Item::print($gr_feature, $opts_hr);
44 }
45 6 ▶ if (@gr_features) {
Branch: 1 branch
BranchTrueFalseTotal
if (@gr_features) 6 0 6
46 6 push @ret, $opts_hr->{'texts'}->{'grammatical_features'}.': '.(join ', ', @gr_features);
47 }
48  
49 # Statements.
50 6 push @ret, print_statements($obj, $opts_hr,
51 \&Wikibase::Datatype::Print::Statement::print);
52  
53 6 ▶ return wantarray ? @ret : (join "\n", @ret);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 2 6
54 }
55  
56 10 1;
57  
58 __END__
« Print/Statement.pm ↑ Summary Print/Lexeme.pm »