Object/ExternalId.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 97.3% 37 / 38 CC 2 SCAR 2.5
CC
2
Cov
100%
BUILD
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Object/People.pm ↑ Summary Object/Publisher.pm »
1 package MARC::Convert::Wikidata::Object::ExternalId;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use Mo qw(build is);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Mo::utils 0.15 qw(check_bool check_required check_strings);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 11 Readonly::Array our @NAMES => qw(cnb lccn nkcr_aut);
11  
12 11 our $VERSION = 0.15;
13  
14 11 has deprecated => (
15 is => 'ro',
16 );
17  
18 11 has name => (
19 is => 'ro',
20 );
21  
22 11 has value => (
23 is => 'ro',
24 );
25  
26 sub BUILD {
27 14 ▶ my $self = shift;
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
28  
29 # Check 'deprecated'.
30 14 ▶ if (! $self->{'deprecated'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"deprecated"}) 12 2 14
31 12 $self->{'deprecated'} = 0;
32 }
33 14 check_bool($self, 'deprecated');
34  
35 # Check 'name'.
36 13 check_required($self, 'name');
37 12 check_strings($self, 'name', \@NAMES);
38  
39 # Check 'value'.
40 11 check_required($self, 'value');
41  
42 10 return;
43 }
44  
45 11 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
« Object/People.pm ↑ Summary Object/Publisher.pm »