File Coverage

blib/lib/Wikibase/Datatype/Print/Item.pm
Criterion Covered Total %
statement 41 41 100.0
branch 5 8 62.5
condition n/a
subroutine 10 10 100.0
pod 0 1 0.0
total 56 60 93.3


line stmt bran cond sub pod time code
1             package Wikibase::Datatype::Print::Item;
2              
3 3     3   926564 use base qw(Exporter);
  3         34  
  3         317  
4 3     3   28 use strict;
  3         12  
  3         55  
5 3     3   14 use warnings;
  3         6  
  3         84  
6              
7 3     3   979 use Error::Pure qw(err);
  3         23437  
  3         76  
8 3     3   113 use Readonly;
  3         28  
  3         110  
9 3     3   1427 use Wikibase::Datatype::Print::Sitelink;
  3         8  
  3         492  
10 3     3   1336 use Wikibase::Datatype::Print::Statement;
  3         11  
  3         167  
11 3         151 use Wikibase::Datatype::Print::Utils qw(print_aliases print_descriptions
12 3     3   23 print_labels print_sitelinks print_statements);
  3         6  
13 3     3   18 use Wikibase::Datatype::Print::Value::Monolingual;
  3         8  
  3         792  
14              
15             Readonly::Array our @EXPORT_OK => qw(print);
16              
17             our $VERSION = 0.09;
18              
19             sub print {
20 2     2 0 21238 my ($obj, $opts_hr) = @_;
21              
22 2 50       8 if (! defined $opts_hr) {
23 2         3 $opts_hr = {};
24             }
25              
26 2 50       8 if (! exists $opts_hr->{'lang'}) {
27 2         5 $opts_hr->{'lang'} = 'en';
28             }
29              
30 2 100       52 if (! $obj->isa('Wikibase::Datatype::Item')) {
31 1         6 err "Object isn't 'Wikibase::Datatype::Item'.";
32             }
33              
34 1         3 my @ret;
35              
36             # Label.
37 1         7 push @ret, print_labels($obj, $opts_hr,
38             \&Wikibase::Datatype::Print::Value::Monolingual::print);
39              
40             # Description.
41 1         9 push @ret, print_descriptions($obj, $opts_hr,
42             \&Wikibase::Datatype::Print::Value::Monolingual::print);
43              
44             # Aliases.
45 1         8 push @ret, print_aliases($obj, $opts_hr,
46             \&Wikibase::Datatype::Print::Value::Monolingual::print);
47              
48             # Sitelinks.
49 1         7 push @ret, print_sitelinks($obj, $opts_hr,
50             \&Wikibase::Datatype::Print::Sitelink::print);
51              
52             # Statements.
53 1         7 push @ret, print_statements($obj, $opts_hr,
54             \&Wikibase::Datatype::Print::Statement::print);
55              
56 1 50       30 return wantarray ? @ret : (join "\n", @ret);
57             }
58              
59             1;
60              
61             __END__