File Coverage

blib/lib/Wikibase/Datatype/Print/Value/String.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 28 28 100.0


line stmt bran cond sub pod time code
1             package Wikibase::Datatype::Print::Value::String;
2              
3 44     44   360117 use base qw(Exporter);
  44         150  
  44         4069  
4 44     44   411 use strict;
  44         127  
  44         959  
5 44     44   291 use warnings;
  44         100  
  44         1493  
6              
7 44     44   1195 use Error::Pure qw(err);
  44         23082  
  44         1795  
8 44     44   448 use Readonly;
  44         173  
  44         6879  
9              
10             Readonly::Array our @EXPORT_OK => qw(print);
11              
12             our $VERSION = 0.12;
13              
14             sub print {
15 19     19 1 1239 my ($obj, $opts_hr) = @_;
16              
17 19 100       100 if (! $obj->isa('Wikibase::Datatype::Value::String')) {
18 1         6 err "Object isn't 'Wikibase::Datatype::Value::String'.";
19             }
20              
21 18         100 return $obj->value;
22             }
23              
24             1;
25              
26             __END__
27              
28             =pod
29              
30             =encoding utf8
31              
32             =head1 NAME
33              
34             Wikibase::Datatype::Print::Value::String - Wikibase string value pretty print helpers.
35              
36             =head1 SYNOPSIS
37              
38             use Wikibase::Datatype::Print::Value::String qw(print);
39              
40             my $pretty_print_string = print($obj, $opts_hr);
41              
42             =head1 SUBROUTINES
43              
44             =head2 C<print>
45              
46             my $pretty_print_string = print($obj, $opts_hr);
47              
48             Construct pretty print output for L<Wikibase::Datatype::Value::String>
49             object.
50              
51             Returns string.
52              
53             =head1 ERRORS
54              
55             print():
56             Object isn't 'Wikibase::Datatype::Value::String'.
57              
58             =head1 EXAMPLE
59              
60             =for comment filename=create_and_print_value_string.pl
61              
62             use strict;
63             use warnings;
64              
65             use Wikibase::Datatype::Print::Value::String;
66             use Wikibase::Datatype::Value::String;
67              
68             # Object.
69             my $obj = Wikibase::Datatype::Value::String->new(
70             'value' => 'foo',
71             );
72              
73             # Print.
74             print Wikibase::Datatype::Print::Value::String::print($obj)."\n";
75              
76             # Output:
77             # foo
78              
79             =head1 DEPENDENCIES
80              
81             L<Error::Pure>,
82             L<Exporter>,
83             L<Readonly>.
84              
85             =head1 SEE ALSO
86              
87             =over
88              
89             =item L<Wikibase::Datatype::Value::String>
90              
91             Wikibase string value datatype.
92              
93             =back
94              
95             =head1 REPOSITORY
96              
97             L<https://github.com/michal-josef-spacek/Wikibase-Datatype-Print>
98              
99             =head1 AUTHOR
100              
101             Michal Josef Špaček L<mailto:skim@cpan.org>
102              
103             L<http://skim.cz>
104              
105             =head1 LICENSE AND COPYRIGHT
106              
107             © 2020-2023 Michal Josef Špaček
108              
109             BSD 2-Clause License
110              
111             =head1 VERSION
112              
113             0.12
114              
115             =cut