File Coverage

blib/lib/MARC/Convert/Wikidata/Object/ExternalId.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 31 32 96.8


line stmt bran cond sub pod time code
1             package MARC::Convert::Wikidata::Object::ExternalId;
2              
3 11     11   300301 use strict;
  11         27  
  11         511  
4 11     11   60 use warnings;
  11         23  
  11         961  
5              
6 11     11   5400 use Mo qw(build is);
  11         7774  
  11         65  
7 11     11   26557 use Mo::utils 0.15 qw(check_bool check_required check_strings);
  11         143114  
  11         371  
8 11     11   1770 use Readonly;
  11         31  
  11         2968  
9              
10             Readonly::Array our @NAMES => qw(cnb lccn nkcr_aut);
11              
12             our $VERSION = 0.15;
13              
14             has deprecated => (
15             is => 'ro',
16             );
17              
18             has name => (
19             is => 'ro',
20             );
21              
22             has value => (
23             is => 'ro',
24             );
25              
26             sub BUILD {
27 14     14 0 1583714 my $self = shift;
28              
29             # Check 'deprecated'.
30 14 100       118 if (! $self->{'deprecated'}) {
31 12         59 $self->{'deprecated'} = 0;
32             }
33 14         89 check_bool($self, 'deprecated');
34              
35             # Check 'name'.
36 13         420 check_required($self, 'name');
37 12         143 check_strings($self, 'name', \@NAMES);
38              
39             # Check 'value'.
40 11         828 check_required($self, 'value');
41              
42 10         79 return;
43             }
44              
45             1;
46              
47             __END__
48              
49             =pod
50              
51             =encoding utf8
52              
53             =head1 NAME
54              
55             MARC::Convert::Wikidata::Object::ExternalId - Bibliographic Wikidata object for Kramerius link by MARC record.
56              
57             =head1 SYNOPSIS
58              
59             use MARC::Convert::Wikidata::Object::ExternalId;
60              
61             my $obj = MARC::Convert::Wikidata::Object::ExternalId->new(%params);
62             my $deprecated = $obj->deprecated;
63             my $name = $obj->name;
64             my $value = $obj->value;
65              
66             =head1 METHODS
67              
68             =head2 C<new>
69              
70             my $obj = MARC::Convert::Wikidata::Object::ExternalId->new(%params);
71              
72             Constructor.
73              
74             =over 8
75              
76             =item * C<deprecated>
77              
78             Flag for external id deprecation.
79              
80             Default value is 0.
81              
82             =item * C<name>
83              
84             External id name.
85              
86             Parameter is required.
87              
88             Possible values are:
89              
90             =over
91              
92             =item * cnb
93              
94             Czech national library cnb id.
95              
96             =item * nkcr_aut
97              
98             Czech national library aut id.
99              
100             =item * lccn
101              
102             Library of Congress Control Number.
103              
104             =back
105              
106             =item * C<value>
107              
108             External id value.
109              
110             Parameter is required.
111              
112             =back
113              
114             Returns instance of object.
115              
116             =head2 C<deprecated>
117              
118             my $deprecated = $obj->deprecated;
119              
120             Get deprecated flag.
121              
122             Returns 0/1.
123              
124             =head2 C<name>
125              
126             my $name = $obj->name;
127              
128             Get external id name.
129              
130             Returns string.
131              
132             =head2 C<value>
133              
134             my $value = $obj->value;
135              
136             Get external id value.
137              
138             Returns string.
139              
140             =head1 ERRORS
141              
142             new():
143             From Mo::utils::check_bool():
144             Parameter 'deprecated' must be a bool (0/1).
145             Value: %s
146             From Mo::utils::check_required():
147             Parameter 'name' is required.
148             Parameter 'value' is required.
149             From Mo::utils::check_strings():
150             Parameter 'name' must have strings definition.
151             Parameter 'name' must have right string definition.
152             Parameter 'name' must be one of defined strings.
153             String: %s
154             Possible strings: %s
155              
156             =head1 EXAMPLE1
157              
158             =for comment filename=create_and_dump_external_id.pl
159              
160             use strict;
161             use warnings;
162              
163             use Data::Printer;
164             use MARC::Convert::Wikidata::Object::ExternalId;
165              
166             my $obj = MARC::Convert::Wikidata::Object::ExternalId->new(
167             'name' => 'cnb',
168             'value' => 'cnb003597104',
169             );
170              
171             p $obj;
172              
173             # Output:
174             # MARC::Convert::Wikidata::Object::ExternalId {
175             # parents: Mo::Object
176             # public methods (3):
177             # BUILD
178             # Mo::utils:
179             # check_bool, check_required
180             # private methods (0)
181             # internals: {
182             # deprecated 0,
183             # name "cnb",
184             # value "cnb003597104"
185             # }
186             # }
187              
188             =head1 DEPENDENCIES
189              
190             L<Mo>,
191             L<Mo::utils>,
192             L<Readonly>.
193              
194             =head1 SEE ALSO
195              
196             =over
197              
198             =item L<MARC::Convert::Wikidata>
199              
200             Conversion class between MARC record and Wikidata object.
201              
202             =back
203              
204             =head1 REPOSITORY
205              
206             L<https://github.com/michal-josef-spacek/MARC-Convert-Wikidata-Object>
207              
208             =head1 AUTHOR
209              
210             Michal Josef Špaček L<mailto:skim@cpan.org>
211              
212             L<http://skim.cz>
213              
214             =head1 LICENSE AND COPYRIGHT
215              
216             © Michal Josef Špaček 2021-2025
217              
218             BSD 2-Clause License
219              
220             =head1 VERSION
221              
222             0.15
223              
224             =cut