File Coverage

blib/lib/MARC/Convert/Wikidata/Object/Publisher.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 25 26 96.1


line stmt bran cond sub pod time code
1             package MARC::Convert::Wikidata::Object::Publisher;
2              
3 11     11   199244 use strict;
  11         25  
  11         495  
4 11     11   57 use warnings;
  11         22  
  11         792  
5              
6 11     11   3492 use Mo qw(build default is);
  11         4928  
  11         72  
7 11     11   27698 use Mo::utils 0.21 qw(check_required);
  11         112241  
  11         432  
8 11     11   6872 use Mo::utils::Array qw(check_array_object);
  11         27275  
  11         640  
9              
10             our $VERSION = 0.15;
11              
12             has external_ids => (
13             default => [],
14             is => 'ro',
15             );
16              
17             has id => (
18             is => 'ro',
19             );
20              
21             has name => (
22             is => 'ro',
23             );
24              
25             has place => (
26             is => 'ro',
27             );
28              
29             sub BUILD {
30 14     14 0 1752741 my $self = shift;
31              
32             # Check 'external_ids'.
33 14         103 check_array_object($self, 'external_ids', 'MARC::Convert::Wikidata::Object::ExternalId');
34              
35             # Check 'name'.
36 14         299 check_required($self, 'name');
37              
38 13         108 return;
39             }
40              
41             1;
42              
43             __END__
44              
45             =pod
46              
47             =encoding utf8
48              
49             =head1 NAME
50              
51             MARC::Convert::Wikidata::Object::Publisher - Bibliographic Wikidata object for publisher defined by MARC record.
52              
53             =head1 SYNOPSIS
54              
55             use MARC::Convert::Wikidata::Object::Publisher;
56              
57             my $obj = MARC::Convert::Wikidata::Object::Publisher->new(%params);
58             my $external_ids_ar = $obj->external_ids;
59             my $id = $obj->id;
60             my $name = $obj->name;
61             my $place = $obj->place;
62              
63             =head1 METHODS
64              
65             =head2 C<new>
66              
67             my $obj = MARC::Convert::Wikidata::Object::Publisher->new(%params);
68              
69             Constructor.
70              
71             Returns instance of object.
72              
73             =over 8
74              
75             =item * C<external_ids>
76              
77             External ids.
78              
79             Need to be a reference to array with L<MARC::Convert::Wikidata::Object::ExternalId> instances.
80              
81             Default value is [].
82              
83             =item * C<id>
84              
85             Id of publishing house.
86              
87             Parameter is optional.
88              
89             Default value is undef.
90              
91             =item * C<name>
92              
93             Name of publishing house.
94              
95             Parameter is required.
96              
97             Default value is undef.
98              
99             =item * C<place>
100              
101             Location of publishing house.
102              
103             Default value is undef.
104              
105             =back
106              
107             =head2 C<external_ids>
108              
109             my $external_ids_ar = $obj->external_ids;
110              
111             Get list of external ids.
112              
113             Returns reference to array with L<MARC::Convert::Wikidata::Object::ExternalId> instances.
114              
115             =head2 C<id>
116              
117             my $id = $obj->id;
118              
119             Get id of publishing house.
120              
121             Returns string.
122              
123             =head2 C<name>
124              
125             my $name = $obj->name;
126              
127             Get name of publishing house.
128              
129             Returns string.
130              
131             =head2 C<place>
132              
133             my $place = $obj->place;
134              
135             Get place of publishing house.
136              
137             Returns string.
138              
139             =head1 ERRORS
140              
141             new():
142             From Mo::utils::Array::check_array_object():
143             Parameter 'external_ids' must be a array.
144             Value: %s
145             Reference: %s
146             Parameter 'external_ids' with array must contain 'MARC::Convert::Wikidata::Object::ExternalId' objects.
147             Value: %s
148             Reference: %s
149              
150             From Mo::utils::check_required():
151             Parameter 'name' is required.
152              
153             =head1 EXAMPLE1
154              
155             =for comment filename=create_and_dump_publisher.pl
156              
157             use strict;
158             use warnings;
159              
160             use Data::Printer;
161             use MARC::Convert::Wikidata::Object::ExternalId;
162             use MARC::Convert::Wikidata::Object::Publisher;
163            
164             my $obj = MARC::Convert::Wikidata::Object::Publisher->new(
165             'external_ids' => [
166             MARC::Convert::Wikidata::Object::ExternalId->new(
167             'name' => 'nkcr_aut',
168             'value' => 'ko2002101950',
169             ),
170             ],
171             'id' => '000010003',
172             'name' => 'Academia',
173             'place' => 'Praha',
174             );
175            
176             p $obj;
177              
178             # Output:
179             # MARC::Convert::Wikidata::Object::Publisher {
180             # parents: Mo::Object
181             # public methods (3):
182             # BUILD
183             # Mo::utils:
184             # check_required
185             # Mo::utils::Array:
186             # check_array_object
187             # private methods (0)
188             # internals: {
189             # external_ids [
190             # [0] MARC::Convert::Wikidata::Object::ExternalId
191             # ],
192             # id "000010003" (dualvar: 10003),
193             # name "Academia",
194             # place "Praha"
195             # }
196             # }
197              
198             =head1 DEPENDENCIES
199              
200             L<Mo>,
201             L<Mo::utils>,
202             L<Mo::utils::Array>.
203              
204             =head1 SEE ALSO
205              
206             =over
207              
208             =item L<MARC::Convert::Wikidata>
209              
210             Conversion class between MARC record and Wikidata object.
211              
212             =back
213              
214             =head1 REPOSITORY
215              
216             L<https://github.com/michal-josef-spacek/MARC-Convert-Wikidata-Object>
217              
218             =head1 AUTHOR
219              
220             Michal Josef Špaček L<mailto:skim@cpan.org>
221              
222             L<http://skim.cz>
223              
224             =head1 LICENSE AND COPYRIGHT
225              
226             © Michal Josef Špaček 2021-2025
227              
228             BSD 2-Clause License
229              
230             =head1 VERSION
231              
232             0.15
233              
234             =cut