Identifier.pm

filter: Statementstmt 54.3% 338 / 622 Branchbran 37.3% 156 / 418 Conditioncond 32.4% 104 / 321 MC/DCmcdc 13.9% 26 / 187 Subroutinesub 69.0% 29 / 42 Podpod 100% 23 / 23 totaltotal 41.9% 676 / 1613 CC 321 SCAR 73.5
CC
321
Cov
44%
new
2993.2
as
2979.0
cmp
182.0
CRAP 1559.2
↑ Summary Identifier/Cloudlet.pm »
1 #!/usr/bin/perl -w
2  
3 # Copyright (c) 2023-2026 Philipp Schafft
4  
5 # licensed under Artistic License 2.0 (see LICENSE file)
6  
7 # ABSTRACT: format independent identifier object
8  
9  
10 package Data::Identifier;
11  
12 8 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 8 ▶use parent qw(Data::Identifier::Interface::Known Data::Identifier::Interface::Userdata Data::Identifier::Interface::Simple);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 8 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 8 ▶use Math::BigInt lib => 'GMP';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 8 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 8 our $VERSION = v0.39;
23  
24 8 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
25 8 RE_UUID => qr/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/,
26 RE_OID => qr/^[0-2](?:\.(?:0|[1-9][0-9]*))+\z/,
27 RE_URI => qr/^[a-zA-Z][a-zA-Z0-9\+\.\-]+:/,
28 RE_UINT => qr/^(?:0|[1-9][0-9]*)\z/,
29 RE_SINT => qr/^(?:0|-?[1-9][0-9]*)\z/,
30 RE_QID => qr/^[QPL][1-9][0-9]*\z/,
31 RE_DOI => qr/^10\.[1-9][0-9]+(?:\.[0-9]+)*\/./,
32 RE_GTIN => qr/^[0-9]{8}(?:[0-9]{4,6})?\z/,
33 RE_UNICODE => qr/^U\+([0-9A-F]{4,7})\z/,
34 RE_SIMPLE_TAG => qr/^[^\p{upper case}\s:]+\z/,
35 8 };
36  
37 8 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
38 8 WK_NULL => '00000000-0000-0000-0000-000000000000', # NULL, undef, ...
39 WK_UUID => '8be115d2-dc2f-4a98-91e1-a6e3075cbc31', # uuid
40 WK_OID => 'd08dc905-bbf6-4183-b219-67723c3c8374', # oid
41 WK_URI => 'a8d1637d-af19-49e9-9ef8-6bc1fbcf6439', # uri
42 WK_SID => 'f87a38cb-fd13-4e15-866c-e49901adbec5', # small-identifier
43 WK_WD => 'ce7aae1e-a210-4214-926a-0ebca56d77e3', # wikidata-identifier
44 WK_GTIN => '82d529be-0f00-4b4f-a43f-4a22de5f5312', # gtin
45 WK_IBAN => 'b1418262-6bc9-459c-b4b0-a054d77db0ea', # iban
46 WK_BIC => 'c8a3a132-f160-473c-b5f3-26a748f37e62', # bic
47 WK_DOI => '931f155e-5a24-499b-9fbb-ed4efefe27fe', # doi
48 WK_FC => 'd576b9d1-47d4-43ae-b7ec-bbea1fe009ba', # factgrid-identifier
49 WK_UNICODE_CP => '5f167223-cc9c-4b2f-9928-9fe1b253b560', # unicode-code-point
50 WK_SNI => '039e0bb7-5dd3-40ee-a98c-596ff6cce405', # sirtx-numerical-identifier
51 WK_HDI => 'f8eb04ef-3b8a-402c-ad7c-1e6814cb1998', # host-defined-identifier
52 WK_UDI => '05af99f9-4578-4b79-aabe-946d8e6f5888', # user-defined-identifier
53 WK_CHAT0W => '2c7e15ed-aa2f-4e2f-9a1d-64df0c85875a', # chat-0-word-identifier
54  
55 NS_WD => '9e10aca7-4a99-43ac-9368-6cbfa43636df', # Wikidata-namespace
56 NS_FC => '6491f7a9-0b29-4ef1-992c-3681cea18182', # factgrid-namespace
57 NS_INT => '5dd8ddbb-13a8-4d6c-9264-36e6dd6f9c99', # integer-namespace
58 NS_DATE => 'fc43fbba-b959-4882-b4c8-90a288b7d416', # gregorian-date-namespace
59 NS_GTIN => 'd95d8b1f-5091-4642-a6b0-a585313915f1', # gtin-namespace
60 NS_UNICODE_CP => '132aa723-a373-48bf-a88d-69f1e00f00cf', # unicode-character-namespace
61 8 };
62  
63 # Features:
64 8 my $enabled_oid = 1;
65  
66 8 my %uuid_to_uriid_org = (
67 WK_UUID() => 'uuid',
68 WK_OID() => 'oid',
69 WK_URI() => 'uri',
70 WK_SID() => 'sid',
71 WK_GTIN() => 'gtin',
72 WK_WD() => 'wikidata-identifier',
73 );
74  
75 8 my %uuid_org_to_uuid = map {$uuid_to_uriid_org{$_} => $_} keys %uuid_to_uriid_org;
76  
77 8 my $well_known_uuid = __PACKAGE__->new(ise => WK_UUID, validate => RE_UUID);
78  
79 8 my %well_known = (
80 uuid => $well_known_uuid,
81 oid => __PACKAGE__->new($well_known_uuid => WK_OID, validate => RE_OID),
82 uri => __PACKAGE__->new($well_known_uuid => WK_URI, validate => RE_URI),
83 sid => __PACKAGE__->new($well_known_uuid => WK_SID, validate => RE_UINT),
84 sni => __PACKAGE__->new($well_known_uuid => WK_SNI, validate => RE_UINT),
85 wd => __PACKAGE__->new($well_known_uuid => WK_WD, validate => RE_QID, generate => 'id-based'),
86 fc => __PACKAGE__->new($well_known_uuid => WK_FC, validate => RE_QID, generate => 'id-based'),
87 gtin => __PACKAGE__->new($well_known_uuid => WK_GTIN, validate => RE_GTIN, generate => 'id-based'),
88 iban => __PACKAGE__->new($well_known_uuid => WK_IBAN),
89 bic => __PACKAGE__->new($well_known_uuid => WK_BIC),
90 doi => __PACKAGE__->new($well_known_uuid => WK_DOI, validate => RE_DOI),
91  
92 # Unofficial, not part of public API:
93 # Also used by Data::Identifier::Util!
94 unicodecp => __PACKAGE__->new($well_known_uuid => WK_UNICODE_CP, validate => RE_UNICODE, generate => 'id-based'),
95 chat0w => __PACKAGE__->new($well_known_uuid => WK_CHAT0W, validate => RE_UINT),
96  
97 hdi => __PACKAGE__->new($well_known_uuid => WK_HDI, validate => RE_UINT),
98 udi => __PACKAGE__->new($well_known_uuid => WK_UDI, validate => RE_UINT),
99 null => __PACKAGE__->new($well_known_uuid => WK_NULL),
100 );
101  
102 8 my %registered;
103  
104 8 $_->register foreach values %well_known;
105  
106 8 my %perl_package_registrations;
107  
108 # Refill with namespaces:
109 {
110 8 my %ns = (
111 wd => NS_WD,
112 fc => NS_FC,
113 gtin => NS_GTIN,
114 unicodecp => NS_UNICODE_CP,
115 );
116  
117 8 foreach my $wk (keys %ns) {
118 32 ▶ $well_known{$wk}->{namespace} //= Data::Identifier->new(ise => $ns{$wk})->register;
Condition33%1/3
$well_known{$wk}{"namespace"} //= "Data::Identifier"->new("ise", $ns{$wk})->register
l!l&&r!l&&!r
0320
MC/DC0%0/2
$well_known{$wk}{"namespace"} //= "Data::Identifier"->new("ise", $ns{$wk})->register
$well_known{$wk}{"namespace"} "Data::Identifier"->new("ise", $ns{$wk})->register
Truth table33%1/3
A //= B
A= $well_known{$wk}{"namespace"}B= "Data::Identifier"->new("ise", $ns{$wk})->register
ABresult
1X1
011
000
119 }
120 }
121  
122 # Refill with sids:
123 {
124 8 my %wk_sids = (
125 WK_NULL() => 0, # NULL
126 'ddd60c5c-2934-404f-8f2d-fcb4da88b633' => 1, # also-shares-identifier
127 WK_UUID() => 2,
128 'bfae7574-3dae-425d-89b1-9c087c140c23' => 3, # tagname
129 '7f265548-81dc-4280-9550-1bd0aa4bf748' => 4, # has-type
130 WK_URI() => 5,
131 WK_OID() => 6,
132 # Unassigned: 7
133 'd0a4c6e2-ce2f-4d4c-b079-60065ac681f1' => 8, # language-tag-identifier
134 WK_WD() => 9,
135 '923b43ae-a50e-4db3-8655-ed931d0dd6d4' => 10, # specialises
136 'eacbf914-52cf-4192-a42c-8ecd27c85ee1' => 11, # unicode-string
137 '928d02b0-7143-4ec9-b5ac-9554f02d3fb1' => 12, # integer
138 'dea3782c-6bcb-4ce9-8a39-f8dab399d75d' => 13, # unsigned-integer
139 # Unassigned: 14, 15
140 '6ba648c2-3657-47c2-8541-9b73c3a9b2b4' => 16, # default-context
141 '52a516d0-25d8-47c7-a6ba-80983e576c54' => 17, # proto-file
142 '1cd4a6c6-0d7c-48d1-81e7-4e8d41fdb45d' => 18, # final-file-size
143 '6085f87e-4797-4bb2-b23d-85ff7edc1da0' => 19, # text-fragment
144 '4c9656eb-c130-42b7-9348-a1fee3f42050' => 20, # also-list-contains-also
145 '298ef373-9731-491d-824d-b2836250e865' => 21, # proto-message
146 '7be4d8c7-6a75-44cc-94f7-c87433307b26' => 22, # proto-entity
147 '65bb36f2-b558-48af-8512-bca9150cca85' => 23, # proxy-type
148 'a1c478b5-0a85-4b5b-96da-d250db14a67c' => 24, # flagged-as
149 '59cfe520-ba32-48cc-b654-74f7a05779db' => 25, # marked-as
150 '2bffc55d-7380-454e-bd53-c5acd525d692' => 26, # roaraudio-error-number
151 WK_SID() => 27,
152 'd2750351-aed7-4ade-aa80-c32436cc6030' => 28, # also-has-role
153 '11d8962c-0a71-4d00-95ed-fa69182788a8' => 29, # also-has-comment
154 '30710bdb-6418-42fb-96db-2278f3bfa17f' => 30, # also-has-description
155 # Unassigned: 31
156 '448c50a8-c847-4bc7-856e-0db5fea8f23b' => 32, # final-file-encoding
157 '79385945-0963-44aa-880a-bca4a42e9002' => 33, # final-file-hash
158 '3fde5688-6e34-45e9-8f33-68f079b152c8' => 34, # SEEK_SET
159 'bc598c52-642e-465b-b079-e9253cd6f190' => 35, # SEEK_CUR
160 '06aff30f-70e8-48b4-8b20-9194d22fc460' => 36, # SEEK_END
161 '59a5691a-6a19-4051-bc26-8db82c019df3' => 37, # inode
162 WK_CHAT0W() => 112, # chat-0-word-identifier
163 WK_SNI() => 113, # sirtx-numerical-identifier
164 WK_GTIN() => 160,
165 );
166  
167 8 foreach my $ise (keys %wk_sids) {
168 296 my $identifier = __PACKAGE__->new(ise => $ise);
169 296 ▶ $identifier->{id_cache} //= {};
Condition100%2/2
$identifier->{"id_cache"} //= {}
l!l
72224
MC/DC100%1/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table100%2/2
A
A= $identifier->{"id_cache"}
Aresult
11
00
170 296 ▶ $identifier->{id_cache}->{WK_SID()} //= $wk_sids{$ise};
Condition33%1/3
$identifier->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"} //= $wk_sids{$ise}
l!l&&r!l&&!r
02960
MC/DC0%0/2
$identifier->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"} //= $wk_sids{$ise}
$identifier->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"} $wk_sids{$ise}
Truth table33%1/3
A //= B
A= $identifier->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"}B= $wk_sids{$ise}
ABresult
1X1
011
000
171 296 $identifier->register; # re-register
172 }
173 }
174  
175 # Refill with snis:
176 {
177 8 my %wk_snis = (
178 WK_NULL() => 0, # NULL
179 '039e0bb7-5dd3-40ee-a98c-596ff6cce405' => 10, # sirtx-numerical-identifier
180 'f87a38cb-fd13-4e15-866c-e49901adbec5' => 115, # small-identifier
181 '2bffc55d-7380-454e-bd53-c5acd525d692' => 116, # roaraudio-error-number
182 WK_CHAT0W() => 118, # chat-0-word-identifier
183 WK_UUID() => 119,
184 WK_OID() => 120,
185 WK_URI() => 121,
186 WK_WD() => 123,
187 );
188  
189 8 foreach my $ise (keys %wk_snis) {
190 72 my $identifier = __PACKAGE__->new(ise => $ise);
191 72 ▶ $identifier->{id_cache} //= {};
Condition50%1/2
$identifier->{"id_cache"} //= {}
l!l
720
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table50%1/2
A
A= $identifier->{"id_cache"}
Aresult
11
00
192 72 ▶ $identifier->{id_cache}->{WK_SNI()} //= $wk_snis{$ise};
Condition33%1/3
$identifier->{"id_cache"}{"039e0bb7-5dd3-40ee-a98c-596ff6cce405"} //= $wk_snis{$ise}
l!l&&r!l&&!r
0720
MC/DC0%0/2
$identifier->{"id_cache"}{"039e0bb7-5dd3-40ee-a98c-596ff6cce405"} //= $wk_snis{$ise}
$identifier->{"id_cache"}{"039e0bb7-5dd3-40ee-a98c-596ff6cce405"} $wk_snis{$ise}
Truth table33%1/3
A //= B
A= $identifier->{"id_cache"}{"039e0bb7-5dd3-40ee-a98c-596ff6cce405"}B= $wk_snis{$ise}
ABresult
1X1
011
000
193 72 $identifier->register; # re-register
194 }
195 }
196  
197 # Update NULL:
198 {
199 8 my $identifier = __PACKAGE__->new(uuid => WK_NULL);
200 8 ▶ $identifier->{id_cache} //= {};
Condition50%1/2
$identifier->{"id_cache"} //= {}
l!l
80
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table50%1/2
A
A= $identifier->{"id_cache"}
Aresult
11
00
201 8 foreach my $type (WK_HDI, WK_CHAT0W) {
202 16 ▶ $identifier->{id_cache}->{$type} //= 0;
Condition50%1/2
$identifier->{"id_cache"}{$type} //= 0
l!l
016
MC/DC0%0/1
$identifier->{"id_cache"}{$type} //= 0
$identifier->{"id_cache"}{$type}
Truth table50%1/2
A
A= $identifier->{"id_cache"}{$type}
Aresult
11
00
203 }
204 8 $identifier->register;
205 }
206  
207 # Some extra tags such as namespaces:
208 8 foreach my $ise (NS_WD, NS_INT, NS_DATE) {
209 24 my $identifier = __PACKAGE__->new(ise => $ise);
210 24 $identifier->register; # re-register
211 }
212  
213 # Refill with tagnames
214 {
215 8 my %tagnames = (
216 WK_NULL() => 'null',
217 WK_UUID() => 'uuid',
218 WK_OID() => 'oid',
219 WK_URI() => 'uri',
220 WK_SID() => 'small-identifier',
221 WK_WD() => 'wikidata-identifier',
222 WK_GTIN() => 'gtin',
223 WK_IBAN() => 'iban',
224 WK_BIC() => 'bic',
225 WK_DOI() => 'doi',
226 WK_FC() => 'factgrid-identifier',
227 WK_UNICODE_CP() => 'unicode-code-point',
228 WK_SNI() => 'sirtx-numerical-identifier',
229 WK_HDI() => 'host-defined-identifier',
230 WK_UDI() => 'user-defined-identifier',
231 WK_CHAT0W() => 'chat-0-word-identifier',
232 NS_WD() => 'Wikidata-namespace',
233 NS_FC() => 'factgrid-namespace',
234 NS_INT() => 'integer-namespace',
235 NS_DATE() => 'gregorian-date-namespace',
236 NS_UNICODE_CP() => 'unicode-character-namespace',
237  
238 'ddd60c5c-2934-404f-8f2d-fcb4da88b633' => 'also-shares-identifier',
239 'bfae7574-3dae-425d-89b1-9c087c140c23' => 'tagname',
240 '7f265548-81dc-4280-9550-1bd0aa4bf748' => 'has-type',
241 'd0a4c6e2-ce2f-4d4c-b079-60065ac681f1' => 'language-tag-identifier',
242 '923b43ae-a50e-4db3-8655-ed931d0dd6d4' => 'specialises',
243 'eacbf914-52cf-4192-a42c-8ecd27c85ee1' => 'unicode-string',
244 '928d02b0-7143-4ec9-b5ac-9554f02d3fb1' => 'integer',
245 'dea3782c-6bcb-4ce9-8a39-f8dab399d75d' => 'unsigned-integer',
246 '6ba648c2-3657-47c2-8541-9b73c3a9b2b4' => 'default-context',
247 '52a516d0-25d8-47c7-a6ba-80983e576c54' => 'proto-file',
248 '1cd4a6c6-0d7c-48d1-81e7-4e8d41fdb45d' => 'final-file-size',
249 '6085f87e-4797-4bb2-b23d-85ff7edc1da0' => 'text-fragment',
250 '4c9656eb-c130-42b7-9348-a1fee3f42050' => 'also-list-contains-also',
251 '298ef373-9731-491d-824d-b2836250e865' => 'proto-message',
252 '7be4d8c7-6a75-44cc-94f7-c87433307b26' => 'proto-entity',
253 '65bb36f2-b558-48af-8512-bca9150cca85' => 'proxy-type',
254 'a1c478b5-0a85-4b5b-96da-d250db14a67c' => 'flagged-as',
255 '59cfe520-ba32-48cc-b654-74f7a05779db' => 'marked-as',
256 '2bffc55d-7380-454e-bd53-c5acd525d692' => 'roaraudio-error-number',
257 'd2750351-aed7-4ade-aa80-c32436cc6030' => 'also-has-role',
258 '11d8962c-0a71-4d00-95ed-fa69182788a8' => 'also-has-comment',
259 '30710bdb-6418-42fb-96db-2278f3bfa17f' => 'also-has-description',
260 '448c50a8-c847-4bc7-856e-0db5fea8f23b' => 'final-file-encoding',
261 '79385945-0963-44aa-880a-bca4a42e9002' => 'final-file-hash',
262 '3fde5688-6e34-45e9-8f33-68f079b152c8' => 'SEEK_SET',
263 'bc598c52-642e-465b-b079-e9253cd6f190' => 'SEEK_CUR',
264 '06aff30f-70e8-48b4-8b20-9194d22fc460' => 'SEEK_END',
265 '59a5691a-6a19-4051-bc26-8db82c019df3' => 'inode',
266 '53863a15-68d4-448d-bd69-a9b19289a191' => 'unsigned-integer-generator',
267 'e8aa9e01-8d37-4b4b-8899-42ca0a2a906f' => 'signed-integer-generator',
268 'd74f8c35-bcb8-465c-9a77-01010e8ed25c' => 'unicode-character-generator',
269 '55febcc4-6655-4397-ae3d-2353b5856b34' => 'rgb-colour-generator',
270 '97b7f241-e1c5-4f02-ae3c-8e31e501e1dc' => 'date-generator',
271 '19659233-0a22-412c-bdf1-8ee9f8fc4086' => 'multiplicity-generator',
272 '5ec197c3-1406-467c-96c7-4b1a6ec2c5c9' => 'minimum-multiplicity-generator',
273 );
274  
275 8 foreach my $ise (keys %tagnames) {
276 448 my $identifier = __PACKAGE__->new(ise => $ise);
277 448 ▶ $identifier->{tagname} //= [$tagnames{$ise}];
Condition50%1/2
$identifier->{"tagname"} //= [$tagnames{$ise}]
l!l
0448
MC/DC0%0/1
$identifier->{"tagname"} //= [$tagnames{$ise}]
$identifier->{"tagname"}
Truth table50%1/2
A
A= $identifier->{"tagname"}
Aresult
11
00
278 448 $identifier->register; # re-register
279 }
280 }
281  
282 {
283 # ISE -> namespace
284 8 my %namespaces_uint = (
285 '4a7fc2e2-854b-42ec-b24f-c7fece371865' => 'ac59062c-6ba2-44de-9f54-09e28f2c0b5c', # e621-post-identifier: e621-post-namespace
286 'a0a4fae2-be6f-4a51-8326-6110ba845a16' => '69b7ff38-ca78-43a8-b9ea-66cb02312eef', # e621-pool-identifier: e621-pool-namespace
287 '6e3590b6-2a0c-4850-a71f-8ba196a52280' => 'b96e5d94-0767-40fa-9864-5977eb507ae0', # danbooru2chanjp-post-identifier: danbooru2chanjp-post-namespace
288 );
289 8 my %namespaces_sint = (
290 '2bffc55d-7380-454e-bd53-c5acd525d692' => '744eaf4e-ae93-44d8-9ab5-744105222da6', # roaraudio-error-number: roaraudio-error-namespace
291 );
292 8 my %namespaces_simple_tag = (
293 '6fe0dbf0-624b-48b3-b558-0394c14bad6a' => '3623de4d-0dd4-4236-946a-2613467d50f1', # e621tag: e621tag-namespace
294 'c5632c60-5da2-41af-8b60-75810b622756' => '93f2c36b-8cb6-4f2c-924b-98188f224235', # danbooru2chanjp-tag: danbooru2chanjp-tag-namespace
295 );
296  
297 8 foreach my $ise (keys %namespaces_uint) {
298 24 my $identifier = __PACKAGE__->new(ise => $ise);
299 24 ▶ $identifier->{namespace} //= __PACKAGE__->new(ise => $namespaces_uint{$ise});
Condition33%1/3
$identifier->{"namespace"} //= __PACKAGE__->new("ise", $namespaces_uint{$ise})
l!l&&r!l&&!r
0240
MC/DC0%0/2
$identifier->{"namespace"} //= __PACKAGE__->new("ise", $namespaces_uint{$ise})
$identifier->{"namespace"} __PACKAGE__->new("ise", $namespaces_uint{$ise})
Truth table33%1/3
A //= B
A= $identifier->{"namespace"}B= __PACKAGE__->new("ise", $namespaces_uint{$ise})
ABresult
1X1
011
000
300 24 ▶ $identifier->{validate} //= RE_UINT;
Condition50%1/2
$identifier->{"validate"} //= qr/^(?:0|[1-9][0-9]*)\z/u
l!l
024
MC/DC0%0/1
$identifier->{"validate"} //= qr/^(?:0|[1-9][0-9]*)\z/u
$identifier->{"validate"}
Truth table50%1/2
A
A= $identifier->{"validate"}
Aresult
11
00
301 24 ▶ $identifier->{generate} //= 'id-based';
Condition50%1/2
$identifier->{"generate"} //= "id-based"
l!l
024
MC/DC0%0/1
$identifier->{"generate"} //= "id-based"
$identifier->{"generate"}
Truth table50%1/2
A
A= $identifier->{"generate"}
Aresult
11
00
302 24 $identifier->register; # re-register
303 }
304  
305 8 foreach my $ise (keys %namespaces_sint) {
306 8 my $identifier = __PACKAGE__->new(ise => $ise);
307 8 ▶ $identifier->{namespace} //= __PACKAGE__->new(ise => $namespaces_sint{$ise});
Condition33%1/3
$identifier->{"namespace"} //= __PACKAGE__->new("ise", $namespaces_sint{$ise})
l!l&&r!l&&!r
080
MC/DC0%0/2
$identifier->{"namespace"} //= __PACKAGE__->new("ise", $namespaces_sint{$ise})
$identifier->{"namespace"} __PACKAGE__->new("ise", $namespaces_sint{$ise})
Truth table33%1/3
A //= B
A= $identifier->{"namespace"}B= __PACKAGE__->new("ise", $namespaces_sint{$ise})
ABresult
1X1
011
000
308 8 ▶ $identifier->{validate} //= RE_SINT;
Condition50%1/2
$identifier->{"validate"} //= qr/^(?:0|-?[1-9][0-9]*)\z/u
l!l
08
MC/DC0%0/1
$identifier->{"validate"} //= qr/^(?:0|-?[1-9][0-9]*)\z/u
$identifier->{"validate"}
Truth table50%1/2
A
A= $identifier->{"validate"}
Aresult
11
00
309 8 ▶ $identifier->{generate} //= 'id-based';
Condition50%1/2
$identifier->{"generate"} //= "id-based"
l!l
08
MC/DC0%0/1
$identifier->{"generate"} //= "id-based"
$identifier->{"generate"}
Truth table50%1/2
A
A= $identifier->{"generate"}
Aresult
11
00
310 8 $identifier->register; # re-register
311 }
312  
313 8 foreach my $ise (keys %namespaces_simple_tag) {
314 16 my $identifier = __PACKAGE__->new(ise => $ise);
315 16 ▶ $identifier->{namespace} //= __PACKAGE__->new(ise => $namespaces_simple_tag{$ise});
Condition33%1/3
$identifier->{"namespace"} //= __PACKAGE__->new("ise", $namespaces_simple_tag{$ise})
l!l&&r!l&&!r
0160
MC/DC0%0/2
$identifier->{"namespace"} //= __PACKAGE__->new("ise", $namespaces_simple_tag{$ise})
$identifier->{"namespace"} __PACKAGE__->new("ise", $namespaces_simple_tag{$ise})
Truth table33%1/3
A //= B
A= $identifier->{"namespace"}B= __PACKAGE__->new("ise", $namespaces_simple_tag{$ise})
ABresult
1X1
011
000
316 16 ▶ $identifier->{validate} //= RE_SIMPLE_TAG;
Condition50%1/2
$identifier->{"validate"} //= qr/^[^\p{upper case}\s:]+\z/u
l!l
016
MC/DC0%0/1
$identifier->{"validate"} //= qr/^[^\p{upper case}\s:]+\z/u
$identifier->{"validate"}
Truth table50%1/2
A
A= $identifier->{"validate"}
Aresult
11
00
317 16 ▶ $identifier->{generate} //= 'id-based';
Condition50%1/2
$identifier->{"generate"} //= "id-based"
l!l
016
MC/DC0%0/1
$identifier->{"generate"} //= "id-based"
$identifier->{"generate"}
Truth table50%1/2
A
A= $identifier->{"generate"}
Aresult
11
00
318 16 $identifier->register; # re-register
319 }
320  
321 # validate => RE_QID, namespace => NS_FC, generate => 'id-based'
322 }
323  
324 # Call this after after we loaded all our stuff and before anyone else will register stuff:
325 8 __PACKAGE__->_known_provider('wellknown');
326  
327  
328 2529 ▶sub new {
Subroutine new: called CC=108 SCAR=80.0
Pod documented
329 2529 my ($pkg, $type, $id, %opts) = @_;
330 2529 my $self = bless {};
331  
332 2529 ▶ croak 'No type given' unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 2529 2529
333 2529 ▶ croak 'No id given' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 2529 2529
334  
335 2529 ▶ if (!ref($type) && $type eq 'from') {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $type and $type eq "from") 163 2366 2529
Condition100%3/3
not ref $type and $type eq "from"
!ll&&!rl&&r
9521414163
MC/DC100%2/2
not ref $type and $type eq "from"
not ref $type $type eq "from"
Truth table100%3/3
not(A) and B
A= not ref $typeB= $type eq "from"
ABresult
0X0
100
111
336 163 ▶ if (ref($id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $id) { } 30 133 163
337 30 my $from = $id;
338  
339 30 ▶ if ($from->isa('Convert::Color')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from->isa("Convert::Color")) 0 30 30
340 0 ▶ if ($from->isa('Convert::Color::RGB16')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($from->isa('Convert::Color::RGB16')) { } 0 0 0
elsif ($from->isa('Convert::Color::X11')) { } 0 0 0
341 0 require Data::Identifier::Generate;
342  
343 # For now Data::URIID::Colour doesn't support this space.
344 0 ▶ if (exists &Data::URIID::Colour::new) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists &Data::URIID::Colour::new) 0 0 0
345 0 require Convert::Color::RGB8;
346 0 ▶ eval { $opts{displaycolour} //= Data::URIID::Colour->new(from => $from->as_rgb8) };
Condition0%0/3
$opts{"displaycolour"} //= "Data::URIID::Colour"->new("from", $from->as_rgb8)
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"displaycolour"} //= "Data::URIID::Colour"->new("from", $from->as_rgb8)
$opts{"displaycolour"} "Data::URIID::Colour"->new("from", $from->as_rgb8)
Truth table0%0/3
A //= B
A= $opts{"displaycolour"}B= "Data::URIID::Colour"->new("from", $from->as_rgb8)
ABresult
1X1
011
000
347 }
348  
349 0 $from = Data::Identifier::Generate->colour('#'.$from->hex);
350 } elsif ($from->isa('Convert::Color::X11')) {
351 0 require Data::Identifier::Generate;
352 0 my $name = $from->name;
353  
354 # For now Data::URIID::Colour doesn't support this space.
355 0 ▶ if (exists &Data::URIID::Colour::new) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists &Data::URIID::Colour::new) 0 0 0
356 0 require Convert::Color::RGB8;
357 0 ▶ eval { $opts{displaycolour} //= Data::URIID::Colour->new(from => $from->as_rgb8) };
Condition0%0/3
$opts{"displaycolour"} //= "Data::URIID::Colour"->new("from", $from->as_rgb8)
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"displaycolour"} //= "Data::URIID::Colour"->new("from", $from->as_rgb8)
$opts{"displaycolour"} "Data::URIID::Colour"->new("from", $from->as_rgb8)
Truth table0%0/3
A //= B
A= $opts{"displaycolour"}B= "Data::URIID::Colour"->new("from", $from->as_rgb8)
ABresult
1X1
011
000
358 }
359  
360 0 $from = Data::Identifier::Generate->colour('#'.$from->hex, displayname => $name);
361 0 ▶ $from->{id_cache} //= {};
Condition0%0/2
$from->{"id_cache"} //= {}
l!l
00
MC/DC0%0/1
$from->{"id_cache"} //= {}
$from->{"id_cache"}
Truth table0%0/2
A
A= $from->{"id_cache"}
Aresult
11
00
362 0 ▶ $from->{id_cache}{'135032f7-cc60-46ee-8f64-1724c2a56fa2'} //= $name;
Condition0%0/3
$from->{"id_cache"}{"135032f7-cc60-46ee-8f64-1724c2a56fa2"} //= $name
l!l&&r!l&&!r
000
MC/DC0%0/2
$from->{"id_cache"}{"135032f7-cc60-46ee-8f64-1724c2a56fa2"} //= $name
$from->{"id_cache"}{"135032f7-cc60-46ee-8f64-1724c2a56fa2"} $name
Truth table0%0/3
A //= B
A= $from->{"id_cache"}{"135032f7-cc60-46ee-8f64-1724c2a56fa2"}B= $name
ABresult
1X1
011
000
363 } else {
364 0 require Data::URIID::Colour;
365 0 $from = Data::URIID::Colour->new(from => $from);
366 }
367 }
368  
369 30 ▶ if ($from->isa('Data::Identifier')) {
Branch: 12 branches
BranchTrueFalseTotal
if ($from->isa('Data::Identifier')) { } 30 0 30
elsif ($from->isa('URI')) { } 0 0 0
elsif ($from->isa('Mojo::URL')) { } 0 0 0
elsif ($from->isa('Data::URIID::Result')) { } 0 0 0
elsif ($from->isa('Data::URIID::Base') or $from->isa('Data::URIID::Colour') or $from->isa('Data::URIID::Service')) { } 0 0 0
elsif ($from->isa('Data::TagDB::Tag')) { } 0 0 0
elsif ($from->isa('File::FStore::File') or $from->isa('File::FStore::Adder') or $from->isa('File::FStore::Base')) { } 0 0 0
elsif ($from->isa('SIRTX::Datecode')) { } 0 0 0
elsif ($from->isa('Business::ISBN')) { } 0 0 0
elsif ($from->isa('Data::Identifier::Interface::Simple')) { } 0 0 0
elsif ($from->isa('JSON::PP::Boolean') or $from->isa('JSON::XS::Boolean')) { } 0 0 0
elsif ($from->isa('Math::BigInt') || $from->isa('Math::BigRat') || $from->isa('Math::BigFloat') and $from->is_int) { } 0 0 0
370 30 ▶ if (scalar(keys %opts)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %opts) { } 0 30 30
371 0 $type = $from->type;
372 0 $id = $from->id;
373 } else {
374 30 return $from;
375 }
376 } elsif ($from->isa('URI')) {
377 0 $type = 'uri';
378 } elsif ($from->isa('Mojo::URL')) {
379 0 $type = 'uri';
380 0 $id = $from->to_string;
381 } elsif ($from->isa('Data::URIID::Result')) {
382 0 ▶ $opts{displayname} //= sub { return $from->attribute('displayname', default => undef) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$opts{"displayname"} //= sub { return $from->attribute("displayname", "default", undef); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"displayname"} //= sub { return $from->attribute("displayname", "default", undef); }
$opts{"displayname"} sub { return $from->attribute("displayname", "default", undef); }
Truth table0%0/3
A //= B
A= $opts{"displayname"}B= sub { return $from->attribute("displayname", "default", undef); }
ABresult
1X1
011
000
383 0 ▶ $opts{description} //= sub { return $from->attribute('description', default => undef) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$opts{"description"} //= sub { return $from->attribute("description", "default", undef); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"description"} //= sub { return $from->attribute("description", "default", undef); }
$opts{"description"} sub { return $from->attribute("description", "default", undef); }
Truth table0%0/3
A //= B
A= $opts{"description"}B= sub { return $from->attribute("description", "default", undef); }
ABresult
1X1
011
000
384 0 ▶ $opts{displaycolour} //= sub { return $from->attribute('displaycolour', default => undef) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$opts{"displaycolour"} //= sub { return $from->attribute("displaycolour", "default", undef); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"displaycolour"} //= sub { return $from->attribute("displaycolour", "default", undef); }
$opts{"displaycolour"} sub { return $from->attribute("displaycolour", "default", undef); }
Truth table0%0/3
A //= B
A= $opts{"displaycolour"}B= sub { return $from->attribute("displaycolour", "default", undef); }
ABresult
1X1
011
000
385 0 ▶ $opts{icontext} //= sub { return $from->attribute('icon_text', default => undef) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$opts{"icontext"} //= sub { return $from->attribute("icon_text", "default", undef); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"icontext"} //= sub { return $from->attribute("icon_text", "default", undef); }
$opts{"icontext"} sub { return $from->attribute("icon_text", "default", undef); }
Truth table0%0/3
A //= B
A= $opts{"icontext"}B= sub { return $from->attribute("icon_text", "default", undef); }
ABresult
1X1
011
000
386 0 $type = $from->id_type;
387 0 $id = $from->id;
388 ▶ } elsif ($from->isa('Data::URIID::Base') || $from->isa('Data::URIID::Colour') || $from->isa('Data::URIID::Service')) {
Condition0%0/6
$from->isa("Data::URIID::Base") or $from->isa("Data::URIID::Colour") or $from->isa("Data::URIID::Service")
l!l&&r!l&&!r
000
$from->isa("Data::URIID::Base") or $from->isa("Data::URIID::Colour")
l!l&&r!l&&!r
000
MC/DC0%0/3
$from->isa("Data::URIID::Base") or $from->isa("Data::URIID::Colour") or $from->isa("Data::URIID::Service")
$from->isa("Data::URIID::Base") $from->isa("Data::URIID::Colour") $from->isa("Data::URIID::Service")
Truth table0%0/4
A or B or C
A= $from->isa("Data::URIID::Base")B= $from->isa("Data::URIID::Colour")C= $from->isa("Data::URIID::Service")
ABCresult
1XX1
01X1
0011
0000
389 0 ▶ $opts{displayname} //= $from->displayname(default => undef, no_defaults => 1);
Condition0%0/3
$opts{"displayname"} //= $from->displayname("default", undef, "no_defaults", 1)
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"displayname"} //= $from->displayname("default", undef, "no_defaults", 1)
$opts{"displayname"} $from->displayname("default", undef, "no_defaults", 1)
Truth table0%0/3
A //= B
A= $opts{"displayname"}B= $from->displayname("default", undef, "no_defaults", 1)
ABresult
1X1
011
000
390 0 ▶ if ($from->isa('Data::URIID::Colour')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from->isa("Data::URIID::Colour")) 0 0 0
391 0 ▶ $opts{displaycolour} //= $from;
Condition0%0/3
$opts{"displaycolour"} //= $from
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"displaycolour"} //= $from
$opts{"displaycolour"} $from
Truth table0%0/3
A //= B
A= $opts{"displaycolour"}B= $from
ABresult
1X1
011
000
392 0 ▶ $opts{request} //= $from->rgb;
Condition0%0/3
$opts{"request"} //= $from->rgb
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"request"} //= $from->rgb
$opts{"request"} $from->rgb
Truth table0%0/3
A //= B
A= $opts{"request"}B= $from->rgb
ABresult
1X1
011
000
393 0 ▶ $opts{generator} //= state $generator = Data::Identifier->new(uuid => '55febcc4-6655-4397-ae3d-2353b5856b34')->register;
Condition0%0/3
$opts{"generator"} //= (state $generator = "Data::Identifier"->new("uuid", "55febcc4-6655-4397-ae3d-2353b5856b34")->register)
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"generator"} //= (state $generator = "Data::Identifier"->new("uuid", "55febcc4-6655-4397-ae3d-2353b5856b34")->register)
$opts{"generator"} (state $generator = "Data::Identifier"->new("uuid", "55febcc4-6655-4397-ae3d-2353b5856b34")->register)
Truth table0%0/3
A //= B
A= $opts{"generator"}B= (state $generator = "Data::Identifier"->new("uuid", "55febcc4-6655-4397-ae3d-2353b5856b34")->register)
ABresult
1X1
011
000
394 }
395 0 $type = 'ise';
396 0 $id = $from->ise;
397 } elsif ($from->isa('Data::TagDB::Tag')) {
398 0 ▶ $opts{displayname} //= sub { $from->displayname(default => undef, no_defaults => 1) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$opts{"displayname"} //= sub { $from->displayname("default", undef, "no_defaults", 1); }
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"displayname"} //= sub { $from->displayname("default", undef, "no_defaults", 1); }
$opts{"displayname"} sub { $from->displayname("default", undef, "no_defaults", 1); }
Truth table0%0/3
A //= B
A= $opts{"displayname"}B= sub { $from->displayname("default", undef, "no_defaults", 1); }
ABresult
1X1
011
000
399 0 $type = 'ise';
400 0 $id = $from->ise;
401 ▶ } elsif ($from->isa('File::FStore::File') || $from->isa('File::FStore::Adder') || $from->isa('File::FStore::Base')) {
Condition0%0/6
$from->isa("File::FStore::File") or $from->isa("File::FStore::Adder") or $from->isa("File::FStore::Base")
l!l&&r!l&&!r
000
$from->isa("File::FStore::File") or $from->isa("File::FStore::Adder")
l!l&&r!l&&!r
000
MC/DC0%0/3
$from->isa("File::FStore::File") or $from->isa("File::FStore::Adder") or $from->isa("File::FStore::Base")
$from->isa("File::FStore::File") $from->isa("File::FStore::Adder") $from->isa("File::FStore::Base")
Truth table0%0/4
A or B or C
A= $from->isa("File::FStore::File")B= $from->isa("File::FStore::Adder")C= $from->isa("File::FStore::Base")
ABCresult
1XX1
01X1
0011
0000
402 0 $type = 'ise';
403 0 $id = $from->contentise;
404 } elsif ($from->isa('SIRTX::Datecode')) {
405 0 $id = $from->as('Data::Identifier');
406 0 ▶ unless (scalar(keys %opts)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar keys %opts) 0 0 0
407 0 return $from;
408 }
409 0 $type = $from->type;
410 0 $id = $from->id;
411 } elsif ($from->isa('Business::ISBN')) {
412 0 $type = $well_known{gtin};
413 0 $id = $from->as_isbn13->as_string([]);
414 } elsif ($from->isa('Data::Identifier::Interface::Simple')) {
415 # TODO: We cannot call $from->as('Data::Identifier') here as much as that would be fun,
416 # as this might in turn call exactly this code again resulting in a deep recursion.
417 # A future version might come up with some trick here.
418 0 $type = 'ise';
419 0 $id = $from->ise;
420 ▶ } elsif ($from->isa('JSON::PP::Boolean') || $from->isa('JSON::XS::Boolean')) {
Condition0%0/3
$from->isa("JSON::PP::Boolean") or $from->isa("JSON::XS::Boolean")
l!l&&r!l&&!r
000
MC/DC0%0/2
$from->isa("JSON::PP::Boolean") or $from->isa("JSON::XS::Boolean")
$from->isa("JSON::PP::Boolean") $from->isa("JSON::XS::Boolean")
Truth table0%0/3
A or B
A= $from->isa("JSON::PP::Boolean")B= $from->isa("JSON::XS::Boolean")
ABresult
1X1
011
000
421 0 require Data::Identifier::Util;
422 0 return Data::Identifier::Util->from_bool($from);
423 ▶ } elsif (($from->isa('Math::BigInt') || $from->isa('Math::BigRat') || $from->isa('Math::BigFloat')) && $from->is_int) {
Condition0%0/9
$from->isa("Math::BigInt") || $from->isa("Math::BigRat") || $from->isa("Math::BigFloat") and $from->is_int
!ll&&!rl&&r
000
$from->isa("Math::BigInt") or $from->isa("Math::BigRat") or $from->isa("Math::BigFloat")
l!l&&r!l&&!r
000
$from->isa("Math::BigInt") or $from->isa("Math::BigRat")
l!l&&r!l&&!r
000
MC/DC0%0/4
$from->isa("Math::BigInt") || $from->isa("Math::BigRat") || $from->isa("Math::BigFloat") and $from->is_int
$from->isa("Math::BigInt") $from->isa("Math::BigRat") $from->isa("Math::BigFloat") $from->is_int
Truth table0%0/7
A or B or C and D
A= $from->isa("Math::BigInt")B= $from->isa("Math::BigRat")C= $from->isa("Math::BigFloat")D= $from->is_int
ABCDresult
000X0
1XX00
01X00
00100
1XX11
01X11
00111
424 0 require Data::Identifier::Generate;
425 0 return Data::Identifier::Generate->integer($from->bstr);
426 } else {
427 0 my $bad = 1;
428  
429 0 ▶ if (defined(my $r = $perl_package_registrations{ref $from})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $r = $perl_package_registrations{ref $from})) 0 0 0
430 0 ▶ if (defined(my $to_identifier = $r->{to_identifier})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $to_identifier = $r->{"to_identifier"})) 0 0 0
431 0 my @res = $to_identifier->($from);
432 0 ▶ if (scalar(@res) == 2) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @res == 2) { } 0 0 0
elsif (scalar @res == 1) { } 0 0 0
433 0 ($type, $id) = @res;
434 0 $bad = undef;
435 } elsif (scalar(@res) == 1) {
436 0 my ($v) = @res;
437 0 ▶ if (!$v->isa(__PACKAGE__)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $v->isa(__PACKAGE__)) { } 0 0 0
elsif (scalar keys %opts) { } 0 0 0
438 0 return Data::Identifier->new(from => $v, %opts);
439 } elsif (scalar(keys %opts)) {
440 0 $type = $from->type;
441 0 $id = $from->id;
442 0 $bad = undef;
443 } else {
444 0 return $from;
445 }
446 } else {
447 0 croak 'Unsupported return from external converter function';
448 }
449 }
450 }
451 0 ▶ croak 'Unsupported input data' if $bad;
Branch: 1 branch
BranchTrueFalseTotal
if $bad 0 0 0
452 }
453 } else {
454 # If it's not a ref, try as ise.
455 133 $type = 'ise';
456 }
457 }
458  
459 2499 ▶ if (!ref($type) && $type eq 'ise') {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $type and $type eq "ise") 1109 1390 2499
Condition100%3/3
not ref $type and $type eq "ise"
!ll&&!rl&&r
9524381109
MC/DC100%2/2
not ref $type and $type eq "ise"
not ref $type $type eq "ise"
Truth table100%3/3
not(A) and B
A= not ref $typeB= $type eq "ise"
ABresult
0X0
100
111
460 1109 ▶ croak 'Undefined identifier but type is ISE' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 1109 1109
461  
462 1109 ▶ if ($id =~ /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\z/) { # allow less normalised form than RE_UUID
Branch: 3 branches
BranchTrueFalseTotal
if ($id =~ /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\z/u) { } 1097 12 1109
elsif ($id =~ /^[0-2](?:\.(?:0|[1-9][0-9]*))+\z/u) { } 0 12 12
elsif ($id =~ /^[a-zA-Z][a-zA-Z0-9\+\.\-]+:/u) { } 12 0 12
463 1097 $type = $well_known_uuid;
464  
465 # For bootstrap only.
466 1097 ▶ if (!defined($type) && $id eq '8be115d2-dc2f-4a98-91e1-a6e3075cbc31') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $type and $id eq "8be115d2-dc2f-4a98-91e1-a6e3075cbc31") 8 1089 1097
Condition66%2/3
not defined $type and $id eq "8be115d2-dc2f-4a98-91e1-a6e3075cbc31"
!ll&&!rl&&r
108908
MC/DC50%1/2
not defined $type and $id eq "8be115d2-dc2f-4a98-91e1-a6e3075cbc31"
not defined $type $id eq "8be115d2-dc2f-4a98-91e1-a6e3075cbc31"
Truth table66%2/3
not(A) and B
A= not defined $typeB= $id eq "8be115d2-dc2f-4a98-91e1-a6e3075cbc31"
ABresult
0X0
100
111
467 8 $self->{type} = $well_known_uuid = $type = $self;
468 8 $self->{id} = $id;
469 }
470 } elsif ($id =~ RE_OID) {
471 0 $type = 'oid';
472 } elsif ($id =~ RE_URI) {
473 12 $type = 'uri';
474 } else {
475 0 croak 'Not a valid ISE identifier';
476 }
477 }
478  
479 2499 ▶ unless (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $type) 450 2049 2499
480 450 ▶ if ($type =~ /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\z/) { # allow less normalised form than RE_UUID
Branch: 2 branches
BranchTrueFalseTotal
if ($type =~ /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\z/u) { } 6 444 450
elsif ($type eq 'wellknown') { } 35 409 444
481 6 $type = $pkg->new(uuid => $type);
482 6 $type->register;
483 } elsif ($type eq 'wellknown') {
484 35 $self = $well_known{$id};
485 35 ▶ croak 'Unknown well-known' unless defined $self;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self 0 35 35
486 35 return $self;
487 } else {
488 409 $type = $well_known{$type};
489 }
490 415 ▶ croak 'Unknown type name' unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 415 415
491 }
492  
493 2464 ▶ croak 'Not a valid type' unless $type->isa(__PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
unless $type->isa(__PACKAGE__) 0 2464 2464
494  
495 # we normalise URIs first as they may then normalised again
496 2464 ▶ if ($type == ($well_known{uri} // 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == ($well_known{"uri"} // 0)) 236 2228 2464
Condition100%2/2
$well_known{"uri"} // 0
l!l
2336128
MC/DC100%1/1
$well_known{"uri"} // 0
$well_known{"uri"}
Truth table100%2/2
A
A= $well_known{"uri"}
Aresult
11
00
497 236 my $uri = $id.''; # force stringification
498  
499 236 ▶ if ($uri =~ m#^urn:uuid:([0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})\z#) {
Branch: 6 branches
BranchTrueFalseTotal
if ($uri =~ /^urn:uuid:([0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})\z/u) { } 1 235 236
elsif ($uri =~ /^urn:oid:([0-2](?:\.(?:0|[1-9][0-9]*))+)\z/u) { } 0 235 235
elsif ($uri =~ /^urn:isbn:([0-9Xx-]+)\z/u and scalar eval { do { require Business::ISBN; 1 } }) { } 0 235 235
elsif ($uri =~ m[^https?://www\.wikidata\.org/entity/([QPL][1-9][0-9]*)\z]u) { } 0 235 235
elsif ($uri =~ m[^https?://doi\.org/(10\..+)\z]u) { } 0 235 235
elsif ($uri =~ m[^https?://uriid\.org/([^/]+)/[^/]+]u) { } 2 233 235
500 1 $id = $1;
501 1 $type = $well_known_uuid;
502 } elsif ($uri =~ m#^urn:oid:([0-2](?:\.(?:0|[1-9][0-9]*))+)\z#) {
503 0 $id = $1;
504 0 $type = $well_known{oid};
505 0 ▶ } elsif ($uri =~ m#^urn:isbn:([0-9Xx-]+)\z# && scalar(eval {require Business::ISBN; 1})) {
Condition50%1/2
$uri =~ /^urn:isbn:([0-9Xx-]+)\z/u and scalar eval { do { require Business::ISBN; 1 } }
!ll
2350
MC/DC0%0/1
$uri =~ /^urn:isbn:([0-9Xx-]+)\z/u and scalar eval { do { require Business::ISBN; 1 } }
$uri =~ /^urn:isbn:([0-9Xx-]+)\z/u
Truth table50%1/2
A
A= $uri =~ /^urn:isbn:([0-9Xx-]+)\z/u
Aresult
00
11
506 0 $id = Business::ISBN->new($1)->as_isbn13->as_string([]);
507 0 $type = $well_known{gtin};
508 0 ▶ $self->{id_cache} //= {};
Condition0%0/2
$self->{"id_cache"} //= {}
l!l
00
MC/DC0%0/1
$self->{"id_cache"} //= {}
$self->{"id_cache"}
Truth table0%0/2
A
A= $self->{"id_cache"}
Aresult
11
00
509 0 ▶ $self->{id_cache}{WK_URI()} //= $uri;
Condition0%0/3
$self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"} //= $uri
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"} //= $uri
$self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"} $uri
Truth table0%0/3
A //= B
A= $self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"}B= $uri
ABresult
1X1
011
000
510 } elsif ($uri =~ m#^https?://www\.wikidata\.org/entity/([QPL][1-9][0-9]*)\z#) {
511 0 $id = $1;
512 0 $type = $well_known{wd};
513 } elsif ($uri =~ m#^https?://doi\.org/(10\..+)\z#) {
514 0 $id = $1;
515 0 $type = $well_known{doi};
516 } elsif ($uri =~ m#^https?://uriid\.org/([^/]+)/[^/]+#) {
517 2 my $ptype = $1;
518 2 ▶ if (defined($uuid_org_to_uuid{$ptype}) || $ptype =~ RE_UUID) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $uuid_org_to_uuid{$ptype} or $ptype =~ /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u) 2 0 2
Condition66%2/3
defined $uuid_org_to_uuid{$ptype} or $ptype =~ /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u
l!l&&r!l&&!r
110
MC/DC0%0/2
defined $uuid_org_to_uuid{$ptype} or $ptype =~ /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u
defined $uuid_org_to_uuid{$ptype} $ptype =~ /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u
Truth table66%2/3
A or B
A= defined $uuid_org_to_uuid{$ptype}B= $ptype =~ /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u
ABresult
1X1
011
000
519 2 my $u = URI->new($uri);
520 2 my @path_segments = $u->path_segments;
521 2 ▶ if (scalar(@path_segments) == 3 && $path_segments[0] eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @path_segments == 3 and $path_segments[0] eq "") 2 0 2
Condition33%1/3
scalar @path_segments == 3 and $path_segments[0] eq ""
!ll&&!rl&&r
002
MC/DC0%0/2
scalar @path_segments == 3 and $path_segments[0] eq ""
scalar @path_segments == 3 $path_segments[0] eq ""
Truth table33%1/3
A and B
A= scalar @path_segments == 3B= $path_segments[0] eq ""
ABresult
0X0
100
111
522 2 ▶ $type = $pkg->new(uuid => ($uuid_org_to_uuid{$path_segments[1]} // $path_segments[1]));
Condition66%2/3
$uuid_org_to_uuid{$path_segments[1]} // $path_segments[1]
l!l&&r!l&&!r
110
MC/DC0%0/2
$uuid_org_to_uuid{$path_segments[1]} // $path_segments[1]
$uuid_org_to_uuid{$path_segments[1]} $path_segments[1]
Truth table66%2/3
A // B
A= $uuid_org_to_uuid{$path_segments[1]}B= $path_segments[1]
ABresult
1X1
011
000
523 2 $id = $path_segments[2];
524 }
525 }
526 }
527 }
528  
529 2464 ▶ if ($type == ($well_known_uuid // 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type == ($well_known_uuid // 0)) { } 2011 453 2464
elsif ($type == ($well_known{'oid'} // 0)) { } 2 451 453
Condition50%1/2
$well_known_uuid // 0
l!l
24640
MC/DC0%0/1
$well_known_uuid // 0
$well_known_uuid
Truth table50%1/2
A
A= $well_known_uuid
Aresult
11
00
530 2011 $id = lc($id); # normalise
531 ▶ } elsif ($type == ($well_known{oid} // 0)) {
Condition50%1/2
$well_known{"oid"} // 0
l!l
4530
MC/DC0%0/1
$well_known{"oid"} // 0
$well_known{"oid"}
Truth table50%1/2
A
A= $well_known{"oid"}
Aresult
11
00
532 2 ▶ if ($id =~ /^2\.25\.([1-9][0-9]*)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id =~ /^2\.25\.([1-9][0-9]*)\z/u) 1 1 2
533 1 my $hex = Math::BigInt->new($1)->as_hex;
534 1 $hex =~ s/^0x//;
535 1 $hex = ('0' x (32 - length($hex))) . $hex;
536 1 $hex =~ s/^(.{8})(.{4})(.{4})(.{4})(.{12})\z/$1-$2-$3-$4-$5/;
537 1 $type = $well_known_uuid;
538 1 $id = $hex;
539 }
540 }
541  
542 2464 ▶ if (defined($opts{displaycolour}) && !ref($opts{displaycolour})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"displaycolour"} and not ref $opts{"displaycolour"}) 0 2464 2464
Condition33%1/3
defined $opts{"displaycolour"} and not ref $opts{"displaycolour"}
!ll&&!rl&&r
246400
MC/DC0%0/2
defined $opts{"displaycolour"} and not ref $opts{"displaycolour"}
defined $opts{"displaycolour"} not ref $opts{"displaycolour"}
Truth table33%1/3
A and not(B)
A= defined $opts{"displaycolour"}B= not ref $opts{"displaycolour"}
ABresult
0X0
100
111
543 0 croak 'Invalid value for displaycolour passed: not an object. This should be a Data::URIID::Colour';
544 }
545  
546 2464 ▶ if (defined(my $v = $registered{$type->uuid}{$id})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $v = $registered{$type->uuid}{$id})) 796 1668 2464
547 796 foreach my $key (qw(displayname displaycolour icontext description)) {
548 3184 ▶ next unless defined $opts{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{$key} 3127 57 3184
549 57 ▶ $v->{$key} //= $opts{$key};
Condition66%2/3
$v->{$key} //= $opts{$key}
l!l&&r!l&&!r
3540
MC/DC0%0/2
$v->{$key} //= $opts{$key}
$v->{$key} $opts{$key}
Truth table66%2/3
A //= B
A= $v->{$key}B= $opts{$key}
ABresult
1X1
011
000
550 }
551 796 ▶ if (defined(my $tagname = $opts{tagname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $tagname = $opts{"tagname"})) 0 796 796
552 0 ▶ $v->_add_tagnames(ref($tagname) ? @{$tagname} : ($tagname));
Branch: 1 branch
BranchTrueFalseTotal
ref $tagname ? : 0 0 0
553 }
554 796 return $v;
555 }
556  
557  
558 1668 ▶ if (defined $type->{validate}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type->{"validate"}) 1601 67 1668
559 1601 ▶ croak 'Identifier did not validate against type' unless $id =~ $type->{validate};
Branch: 1 branch
BranchTrueFalseTotal
unless $id =~ /$type->{"validate"}/u 0 1601 1601
560 }
561  
562 1668 $self->{type} = $type;
563 1668 $self->{id} = $id;
564  
565 1668 foreach my $key (qw(validate namespace generator request generate displayname displaycolour icontext description)) {
566 15012 ▶ next unless defined $opts{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{$key} 13901 1111 15012
567 1111 ▶ $self->{$key} //= $opts{$key};
Condition33%1/3
$self->{$key} //= $opts{$key}
l!l&&r!l&&!r
011110
MC/DC0%0/2
$self->{$key} //= $opts{$key}
$self->{$key} $opts{$key}
Truth table33%1/3
A //= B
A= $self->{$key}B= $opts{$key}
ABresult
1X1
011
000
568 }
569  
570 1668 foreach my $key (qw(namespace generator)) {
571 3336 ▶ if (defined(my $v = $self->{$key})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $v = $self->{$key})) 3 3333 3336
572 3 ▶ unless (ref $v) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $v) 3 0 3
573 3 $self->{$key} = $pkg->new(from => $v)->register;
574 }
575 }
576 }
577  
578 1668 ▶ if (defined(my $tagname = $opts{tagname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $tagname = $opts{"tagname"})) 0 1668 1668
579 0 my %tagnames;
580 0 ▶ $tagname = [$tagname] unless ref $tagname;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tagname 0 0 0
581 0 %tagnames = map {$_ => undef} grep {defined} @{$tagname};
582 0 $tagname = [keys %tagnames];
583 0 ▶ if (scalar(@{$tagname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$tagname;}) 0 0 0
584 0 $self->{tagname} = $tagname;
585 }
586 }
587  
588 1668 return bless $self;
589 }
590  
591  
592 #@returns __PACKAGE__
593 0 ▶sub random {
Subroutine random: not called CC=6 SCAR=37.4
Pod documented
594 0 my ($pkg, %opts) = @_;
595 0 ▶ my $type = $opts{type} // 'uuid';
Condition0%0/2
$opts{"type"} // "uuid"
l!l
00
MC/DC0%0/1
$opts{"type"} // "uuid"
$opts{"type"}
Truth table0%0/2
A
A= $opts{"type"}
Aresult
11
00
596  
597 0 ▶ if (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type) 0 0 0
598 0 ▶ if ($type == $well_known_uuid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == $well_known_uuid) { } 0 0 0
599 0 $type = 'uuid';
600 } else {
601 0 croak 'Invalid/Unsupported type';
602 }
603 }
604  
605 0 ▶ if ($type ne 'ise' && $type ne 'uuid') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "ise" and $type ne "uuid") 0 0 0
Condition0%0/3
$type ne "ise" and $type ne "uuid"
!ll&&!rl&&r
000
MC/DC0%0/2
$type ne "ise" and $type ne "uuid"
$type ne "ise" $type ne "uuid"
Truth table0%0/3
A and B
A= $type ne "ise"B= $type ne "uuid"
ABresult
0X0
100
111
606 0 croak 'Invalid/Unsupported type';
607 }
608  
609 0 require Data::Identifier::Generate;
610 0 my $uuid = Data::Identifier::Generate->_random(%opts{'sources'});
611 0 return $pkg->new(uuid => $uuid, %opts{'displayname'});
612 }
613  
614  
615  
616 #@returns __PACKAGE__
617 167 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
618 167 my ($self) = @_;
619 167 return $self->{type};
620 }
621  
622  
623  
624 161 ▶sub id {
Subroutine id: called CC=1 SCAR=0.0
Pod documented
625 161 my ($self) = @_;
626 161 return $self->{id};
627 }
628  
629  
630 18250 ▶sub uuid {
Subroutine uuid: called CC=9 SCAR=22.1
Pod documented
631 18250 my ($self, %opts) = @_;
632  
633 18250 ▶ return $self->{id_cache}{WK_UUID()} if !$opts{no_defaults} && defined($self->{id_cache}) && defined($self->{id_cache}{WK_UUID()});
Branch: 1 branch
BranchTrueFalseTotal
if not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"} 1069 17181 18250
Condition100%6/6
not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
!ll&&!rl&&r
2263149181069
not $opts{"no_defaults"} and defined $self->{"id_cache"}
!ll&&!rl&&r
165209815987
MC/DC100%3/3
not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
not $opts{"no_defaults"} defined $self->{"id_cache"} defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
Truth table100%4/4
not(A) and B and C
A= not $opts{"no_defaults"}B= defined $self->{"id_cache"}C= defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
ABCresult
0XX0
10X0
1100
1111
634  
635 17181 ▶ if ($self->{type} == $well_known_uuid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} == $well_known_uuid) 17068 113 17181
636 17068 return $self->{id};
637 }
638  
639 113 ▶ unless ($opts{no_defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"no_defaults"}) 91 22 113
640 # Try to generate a UUID and recheck cache:
641 91 $self->_generate;
642 91 ▶ return $self->{id_cache}{WK_UUID()} if defined($self->{id_cache}) && defined($self->{id_cache}{WK_UUID()});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"id_cache"} and defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"} 67 24 91
Condition66%2/3
defined $self->{"id_cache"} and defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
!ll&&!rl&&r
24067
MC/DC50%1/2
defined $self->{"id_cache"} and defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
defined $self->{"id_cache"} defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
Truth table66%2/3
A and B
A= defined $self->{"id_cache"}B= defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
ABresult
0X0
100
111
643 }
644  
645 46 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 46 0 46
646 0 croak 'Identifier has no valid UUID';
647 }
648  
649 2175 ▶sub oid {
Subroutine oid: called CC=8 SCAR=21.7
Pod documented
650 2175 my ($self, %opts) = @_;
651 2175 my $type = $well_known{oid};
652  
653 2175 ▶ return $self->{id_cache}{WK_OID()} if !$opts{no_defaults} && defined($self->{id_cache}) && defined($self->{id_cache}{WK_OID()});
Branch: 1 branch
BranchTrueFalseTotal
if not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"d08dc905-bbf6-4183-b219-67723c3c8374"} 678 1497 2175
Condition83%5/6
not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"d08dc905-bbf6-4183-b219-67723c3c8374"}
!ll&&!rl&&r
792705678
not $opts{"no_defaults"} and defined $self->{"id_cache"}
!ll&&!rl&&r
07921383
MC/DC66%2/3
not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"d08dc905-bbf6-4183-b219-67723c3c8374"}
not $opts{"no_defaults"} defined $self->{"id_cache"} defined $self->{"id_cache"}{"d08dc905-bbf6-4183-b219-67723c3c8374"}
Truth table75%3/4
not(A) and B and C
A= not $opts{"no_defaults"}B= defined $self->{"id_cache"}C= defined $self->{"id_cache"}{"d08dc905-bbf6-4183-b219-67723c3c8374"}
ABCresult
0XX0
10X0
1100
1111
654  
655 1497 ▶ if ($self->{type} == $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} == $type) 0 1497 1497
656 0 return $self->{id};
657 }
658  
659 1497 ▶ unless ($opts{no_defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"no_defaults"}) 1497 0 1497
660 1497 ▶ if (defined(my $uuid = $self->uuid(default => undef))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $uuid = $self->uuid("default", undef))) 1485 12 1497
661 1485 return $self->{id_cache}{WK_OID()} = sprintf('2.25.%s', Math::BigInt->new('0x'.$uuid =~ tr/-//dr));
662 }
663 }
664  
665 12 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 12 0 12
666 0 croak 'Identifier has no valid OID';
667 }
668  
669 2172 ▶sub uri {
Subroutine uri: called CC=17 SCAR=31.9
Pod documented
670 2172 my ($self, %opts) = @_;
671 2172 my $type = $well_known{uri};
672  
673 2172 ▶ if (!$opts{no_defaults} && !defined($opts{style}) && defined($self->{id_cache}) && defined($self->{id_cache}{WK_URI()})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts{"no_defaults"} || defined $opts{"style"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"}) 666 1506 2172
Condition88%8/9
not $opts{"no_defaults"} || defined $opts{"style"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"}
!ll&&!rl&&r
141492666
not $opts{"no_defaults"} || defined $opts{"style"} and defined $self->{"id_cache"}
!ll&&!rl&&r
1132158
$opts{'no_defaults'} || defined $opts{'style'}
l!l&&r!l&&!r
012171
MC/DC75%3/4
not $opts{"no_defaults"} || defined $opts{"style"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"}
$opts{'no_defaults'} defined $opts{'style'} defined $self->{"id_cache"} defined $self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"}
Truth table80%4/5
not(A || B) and C and D
A= $opts{'no_defaults'}B= defined $opts{'style'}C= defined $self->{"id_cache"}D= defined $self->{"id_cache"}{"a8d1637d-af19-49e9-9ef8-6bc1fbcf6439"}
ABCDresult
1XXX0
01XX0
000X0
00100
00111
674 666 return $self->{id_cache}{WK_URI()};
675 }
676  
677 1506 ▶ if ($self->{type} == $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} == $type) 233 1273 1506
678 233 return $self->{id};
679 }
680  
681 1273 ▶ $opts{style} //= 'urn';
Condition100%2/2
$opts{"style"} //= "urn"
l!l
11272
MC/DC100%1/1
$opts{"style"} //= "urn"
$opts{"style"}
Truth table100%2/2
A
A= $opts{"style"}
Aresult
11
00
682  
683 1273 ▶ unless ($opts{no_defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"no_defaults"}) 1273 0 1273
684 1273 ▶ if ($self->{type} == $well_known{wd}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->{'type'} == $well_known{'wd'}) { } 64 1209 1273
elsif ($self->{'type'} == $well_known{'doi'}) { } 0 1209 1209
elsif (defined(my $uuid = $self->uuid('default', undef)) and $opts{'style'} eq 'urn') { } 1208 1 1209
elsif ($enabled_oid and defined(my $oid = $self->oid('default', undef)) and $opts{'style'} eq 'urn') { } 0 1 1
685 64 return $self->{id_cache}{WK_URI()} = sprintf('http://www.wikidata.org/entity/%s', $self->{id});
686 } elsif ($self->{type} == $well_known{doi}) {
687 0 return $self->{id_cache}{WK_URI()} = sprintf('https://doi.org/%s', $self->{id});
688 ▶ } elsif (defined(my $uuid = $self->uuid(default => undef)) && $opts{style} eq 'urn') {
Condition66%2/3
defined(my $uuid = $self->uuid("default", undef)) and $opts{"style"} eq "urn"
!ll&&!rl&&r
011208
MC/DC50%1/2
defined(my $uuid = $self->uuid("default", undef)) and $opts{"style"} eq "urn"
defined(my $uuid = $self->uuid("default", undef)) $opts{"style"} eq "urn"
Truth table66%2/3
A and B
A= defined(my $uuid = $self->uuid("default", undef))B= $opts{"style"} eq "urn"
ABresult
0X0
100
111
689 1208 return $self->{id_cache}{WK_URI()} = sprintf('urn:uuid:%s', $uuid);
690 ▶ } elsif ($enabled_oid && defined(my $oid = $self->oid(default => undef)) && $opts{style} eq 'urn') {
Condition33%2/6
$enabled_oid and defined(my $oid = $self->oid("default", undef)) and $opts{"style"} eq "urn"
!ll&&!rl&&r
010
$enabled_oid and defined(my $oid = $self->oid("default", undef))
!ll&&!rl&&r
001
MC/DC0%0/3
$enabled_oid and defined(my $oid = $self->oid("default", undef)) and $opts{"style"} eq "urn"
$enabled_oid defined(my $oid = $self->oid("default", undef)) $opts{"style"} eq "urn"
Truth table25%1/4
A and B and C
A= $enabled_oidB= defined(my $oid = $self->oid("default", undef))C= $opts{"style"} eq "urn"
ABCresult
0XX0
10X0
1100
1111
691 0 return $self->{id_cache}{WK_URI()} = sprintf('urn:oid:%s', $oid);
692 } else {
693 1 my $u = URI->new("https://uriid.org/");
694 1 my $type_uuid = $self->{type}->uuid;
695 1 ▶ $u->path_segments('', $uuid_to_uriid_org{$type_uuid} // $type_uuid, $self->{id});
Condition33%1/3
$uuid_to_uriid_org{$type_uuid} // $type_uuid
l!l&&r!l&&!r
100
MC/DC0%0/2
$uuid_to_uriid_org{$type_uuid} // $type_uuid
$uuid_to_uriid_org{$type_uuid} $type_uuid
Truth table33%1/3
A // B
A= $uuid_to_uriid_org{$type_uuid}B= $type_uuid
ABresult
1X1
011
000
696 1 return $self->{id_cache}{WK_URI()} = $u;
697 }
698 }
699  
700 0 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
701 0 croak 'Identifier has no valid URI';
702 }
703  
704 2178 ▶sub sid {
Subroutine sid: called CC=5 SCAR=16.8
Pod documented
705 2178 my ($self, %opts) = @_;
706 2178 my $type = $well_known{sid};
707 2178 ▶ return $self->{id_cache}{WK_SID()} if defined($self->{id_cache}) && defined($self->{id_cache}{WK_SID()});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"id_cache"} and defined $self->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"} 913 1265 2178
Condition100%3/3
defined $self->{"id_cache"} and defined $self->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"}
!ll&&!rl&&r
121253913
MC/DC100%2/2
defined $self->{"id_cache"} and defined $self->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"}
defined $self->{"id_cache"} defined $self->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"}
Truth table100%3/3
A and B
A= defined $self->{"id_cache"}B= defined $self->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"}
ABresult
0X0
100
111
708 1265 ▶ if ($self->{type} == $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} == $type) 0 1265 1265
709 0 return $self->{id};
710 }
711  
712 1265 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 1265 0 1265
713 0 croak 'Identifier has no valid SID';
714 }
715  
716  
717  
718 247 ▶sub ise {
Subroutine ise: called CC=8 SCAR=30.8
Pod documented
719 247 my ($self, %opts) = @_;
720 247 my $type = $self->{type};
721 247 my $have_default = exists $opts{default};
722 247 my $default = delete $opts{default};
723 247 my $value;
724  
725 247 ▶ if ($type == $well_known{uuid} || $type == $well_known{oid} || $type == $well_known{uri}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == $well_known{'uuid'} or $type == $well_known{'oid'} or $type == $well_known{'uri'}) { } 247 0 247
Condition33%2/6
$type == $well_known{"uuid"} or $type == $well_known{"oid"} or $type == $well_known{"uri"}
l!l&&r!l&&!r
24700
$type == $well_known{"uuid"} or $type == $well_known{"oid"}
l!l&&r!l&&!r
24700
MC/DC0%0/3
$type == $well_known{"uuid"} or $type == $well_known{"oid"} or $type == $well_known{"uri"}
$type == $well_known{"uuid"} $type == $well_known{"oid"} $type == $well_known{"uri"}
Truth table25%1/4
A or B or C
A= $type == $well_known{"uuid"}B= $type == $well_known{"oid"}C= $type == $well_known{"uri"}
ABCresult
1XX1
01X1
0011
0000
726 247 $value = $self->{id};
727 } else {
728 0 $opts{default} = undef;
729 0 ▶ $value = $self->uuid(%opts) // $self->oid(%opts) // $self->uri(%opts);
Condition0%0/6
($self->uuid(%opts) // $self->oid(%opts)) // $self->uri(%opts)
l!l&&r!l&&!r
000
$self->uuid(%opts) // $self->oid(%opts)
l!l&&r!l&&!r
000
MC/DC0%0/3
($self->uuid(%opts) // $self->oid(%opts)) // $self->uri(%opts)
$self->uuid(%opts) $self->oid(%opts) $self->uri(%opts)
Truth table0%0/4
A // B // C
A= $self->uuid(%opts)B= $self->oid(%opts)C= $self->uri(%opts)
ABCresult
1XX1
01X1
0011
0000
730 }
731  
732 247 ▶ return $value if defined $value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 247 0 247
733 0 ▶ return $default if $have_default;
Branch: 1 branch
BranchTrueFalseTotal
if $have_default 0 0 0
734 0 croak 'Identifier has no valid ISE';
735 }
736  
737  
738 1194 ▶sub as {
Subroutine as: called CC=79 SCAR=80.0
Pod documented
739 1194 my ($self, $as, %opts) = @_;
740  
741 1194 ▶ $as = $opts{rawtype} if $as eq 'raw' && defined($opts{rawtype});
Branch: 1 branch
BranchTrueFalseTotal
if $as eq "raw" and defined $opts{"rawtype"} 248 946 1194
Condition66%2/3
$as eq "raw" and defined $opts{"rawtype"}
!ll&&!rl&&r
9460248
MC/DC50%1/2
$as eq "raw" and defined $opts{"rawtype"}
$as eq "raw" defined $opts{"rawtype"}
Truth table66%2/3
A and B
A= $as eq "raw"B= defined $opts{"rawtype"}
ABresult
0X0
100
111
742  
743 1194 ▶ if (ref($as) && eval {$as->isa(__PACKAGE__)} && $self->isa(__PACKAGE__)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $as and eval { do { $as->isa(__PACKAGE__) } } and $self->isa(__PACKAGE__)) 6 1188 1194
Condition66%4/6
ref $as and eval { do { $as->isa(__PACKAGE__) } } and $self->isa(__PACKAGE__)
!ll&&!rl&&r
118806
ref $as and eval { do { $as->isa(__PACKAGE__) } }
!ll&&!rl&&r
118806
MC/DC33%1/3
ref $as and eval { do { $as->isa(__PACKAGE__) } } and $self->isa(__PACKAGE__)
ref $as eval { do { $as->isa(__PACKAGE__) } } $self->isa(__PACKAGE__)
Truth table50%2/4
A and B and C
A= ref $asB= eval { do { $as->isa(__PACKAGE__) } }C= $self->isa(__PACKAGE__)
ABCresult
0XX0
10X0
1100
1111
744 6 my $type_uuid = $as->uuid;
745 6 my $next_type;
746  
747 6 ▶ return $self->id if $self->type->eq($as);
Branch: 1 branch
BranchTrueFalseTotal
if $self->type->eq($as) 0 6 6
748  
749 6 foreach my $test (qw(uuid oid uri sid)) {
750 24 ▶ if ($as == $well_known{$test}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($as == $well_known{$test}) 3 21 24
751 3 $next_type = $test;
752 3 last;
753 }
754 }
755  
756 6 ▶ if (defined $next_type) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $next_type) { } 3 3 6
757 3 ▶ return $self->{id_cache}{$type_uuid} if !$opts{no_defaults} && defined($self->{id_cache}) && defined($self->{id_cache}{$type_uuid});
Branch: 1 branch
BranchTrueFalseTotal
if not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid} 0 3 3
Condition33%2/6
not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid}
!ll&&!rl&&r
300
not $opts{"no_defaults"} and defined $self->{"id_cache"}
!ll&&!rl&&r
300
MC/DC0%0/3
not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid}
not $opts{"no_defaults"} defined $self->{"id_cache"} defined $self->{"id_cache"}{$type_uuid}
Truth table25%1/4
not(A) and B and C
A= not $opts{"no_defaults"}B= defined $self->{"id_cache"}C= defined $self->{"id_cache"}{$type_uuid}
ABCresult
0XX0
10X0
1100
1111
758 3 $as = $next_type;
759 } else {
760 3 ▶ return $self->{id_cache}{$type_uuid} if defined($self->{id_cache}) && defined($self->{id_cache}{$type_uuid});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid} 3 0 3
Condition33%1/3
defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid}
!ll&&!rl&&r
003
MC/DC0%0/2
defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid}
defined $self->{"id_cache"} defined $self->{"id_cache"}{$type_uuid}
Truth table33%1/3
A and B
A= defined $self->{"id_cache"}B= defined $self->{"id_cache"}{$type_uuid}
ABresult
0X0
100
111
761 0 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
762 0 croak 'Unknown/Unsupported as: '.$as;
763 }
764 }
765  
766 1191 ▶ return $self if ($as =~ /^[A-Z]/ || $as =~ /::/) && eval {$self->isa($as)};
Branch: 1 branch
BranchTrueFalseTotal
if $as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } } 1188 3 1191
Condition66%4/6
$as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } }
!ll&&!rl&&r
301188
$as =~ /^[A-Z]/u or $as =~ /::/u
l!l&&r!l&&!r
118803
MC/DC33%1/3
$as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } }
$as =~ /^[A-Z]/u $as =~ /::/u eval { do { $self->isa($as) } }
Truth table40%2/5
A or B and C
A= $as =~ /^[A-Z]/uB= $as =~ /::/uC= eval { do { $self->isa($as) } }
ABCresult
00X0
1X00
0100
1X11
0111
767  
768 3 ▶ if ($self->isa('Data::Identifier::Interface::Subobjects')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa("Data::Identifier::Interface::Subobjects")) 0 3 3
769 0 require Data::Identifier::Interface::Subobjects; # Is this required?
770 0 ▶ $opts{$_} //= $self->so_get($_, default => undef) foreach Data::Identifier::Interface::Subobjects->KEYS;
Condition0%0/3
$opts{$_} //= $self->so_get($_, "default", undef)
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{$_} //= $self->so_get($_, "default", undef)
$opts{$_} $self->so_get($_, "default", undef)
Truth table0%0/3
A //= B
A= $opts{$_}B= $self->so_get($_, "default", undef)
ABresult
1X1
011
000
771 }
772  
773 3 ▶ if (defined(my $so = $opts{so})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $so = $opts{"so"})) 0 3 3
774 0 require Data::Identifier::Interface::Subobjects; # Is this required?
775 0 ▶ if (ref($so) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $so eq 'HASH') { } 0 0 0
776 0 ▶ $opts{$_} //= $so->{$_} foreach Data::Identifier::Interface::Subobjects->KEYS;
Condition0%0/3
$opts{$_} //= $so->{$_}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{$_} //= $so->{$_}
$opts{$_} $so->{$_}
Truth table0%0/3
A //= B
A= $opts{$_}B= $so->{$_}
ABresult
1X1
011
000
777 } else {
778 0 ▶ $opts{$_} //= $so->so_get($_, default => undef) foreach Data::Identifier::Interface::Subobjects->KEYS;
Condition0%0/3
$opts{$_} //= $so->so_get($_, "default", undef)
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{$_} //= $so->so_get($_, "default", undef)
$opts{$_} $so->so_get($_, "default", undef)
Truth table0%0/3
A //= B
A= $opts{$_}B= $so->so_get($_, "default", undef)
ABresult
1X1
011
000
779 }
780 }
781  
782 3 ▶ $self = __PACKAGE__->new(from => $self) unless eval {$self->isa(__PACKAGE__)};
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $self->isa(__PACKAGE__) } } 0 3 3
783  
784 0 ▶ return $self if ($as =~ /^[A-Z]/ || $as =~ /::/) && eval {$self->isa($as)}; # Recheck after converting to a Data::Identifier
Branch: 1 branch
BranchTrueFalseTotal
if $as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } } 0 3 3
Condition33%2/6
$as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } }
!ll&&!rl&&r
300
$as =~ /^[A-Z]/u or $as =~ /::/u
l!l&&r!l&&!r
003
MC/DC0%0/3
$as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } }
$as =~ /^[A-Z]/u $as =~ /::/u eval { do { $self->isa($as) } }
Truth table20%1/5
A or B and C
A= $as =~ /^[A-Z]/uB= $as =~ /::/uC= eval { do { $self->isa($as) } }
ABCresult
00X0
1X00
0100
1X11
0111
785  
786 3 ▶ if ($as eq 'uuid' || $as eq 'oid' || $as eq 'uri' || $as eq 'sid' || $as eq 'ise') {
Branch: 14 branches
BranchTrueFalseTotal
if ($as eq 'uuid' or $as eq 'oid' or $as eq 'uri' or $as eq 'sid' or $as eq 'ise') { } 3 0 3
elsif ($as eq __PACKAGE__) { } 0 0 0
elsif ($as eq 'URI') { } 0 0 0
elsif ($as eq 'Mojo::URL') { } 0 0 0
elsif ($as eq 'Data::URIID::Result' and defined $opts{'extractor'}) { } 0 0 0
elsif ($as eq 'Data::URIID::Service' and defined $opts{'extractor'}) { } 0 0 0
elsif ($as eq 'SIRTX::Datecode' and eval { do { require SIRTX::Datecode; 'SIRTX::Datecode'->VERSION(v0.03); 1 } }) { } 0 0 0
elsif ($as eq 'Data::URIID::Colour' and eval { do { require Data::URIID; require Data::URIID::Colour; 'Data::URIID::Colour'->VERSION(v0.14); 1 } }) { } 0 0 0
elsif ($as eq 'Data::TagDB::Tag' and defined $opts{'db'}) { } 0 0 0
elsif ($as eq 'File::FStore::File' and defined $opts{'store'}) { } 0 0 0
elsif ($as eq 'Business::ISBN' and $self->type->eq('gtin')) { } 0 0 0
elsif ($as =~ /^Math::Big(?:Int|Rat|Float)\z/u and defined $self->request('default', undef, 'no_defaults', 1) and eval { do { $self->generator->eq('53863a15-68d4-448d-bd69-a9b19289a191') or $self->generator->eq('e8aa9e01-8d37-4b4b-8899-42ca0a2a906f') } }) { } 0 0 0
elsif ($as =~ /^Convert::Color(?:::.+)?\z/u) { } 0 0 0
elsif (defined(my $r = $perl_package_registrations{$as})) { } 0 0 0
Condition33%4/12
$as eq "uuid" or $as eq "oid" or $as eq "uri" or $as eq "sid" or $as eq "ise"
l!l&&r!l&&!r
300
$as eq "uuid" or $as eq "oid" or $as eq "uri" or $as eq "sid"
l!l&&r!l&&!r
030
$as eq "uuid" or $as eq "oid" or $as eq "uri"
l!l&&r!l&&!r
003
$as eq "uuid" or $as eq "oid"
l!l&&r!l&&!r
003
MC/DC0%0/5
$as eq "uuid" or $as eq "oid" or $as eq "uri" or $as eq "sid" or $as eq "ise"
$as eq "uuid" $as eq "oid" $as eq "uri" $as eq "sid" $as eq "ise"
Truth table16%1/6
A or B or C or D or E
A= $as eq "uuid"B= $as eq "oid"C= $as eq "uri"D= $as eq "sid"E= $as eq "ise"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
787 3 my $func = $self->can($as);
788 3 return $self->$func(%opts);
789 } elsif ($as eq __PACKAGE__) {
790 0 return $self;
791 } elsif ($as eq 'URI') {
792 0 my $had_default = exists $opts{default};
793 0 my $default = delete $opts{default};
794 0 my $val = $self->uri(%opts, default => undef);
795  
796 0 ▶ return URI->new($val) if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 0 0 0
797 0 ▶ if ($had_default) {
Branch: 1 branch
BranchTrueFalseTotal
if ($had_default) 0 0 0
798 0 ▶ return $default if ref $default;
Branch: 1 branch
BranchTrueFalseTotal
if ref $default 0 0 0
799 0 return URI->new($default);
800 }
801 0 croak 'No value for URI';
802 } elsif ($as eq 'Mojo::URL') {
803 0 my $had_default = exists $opts{default};
804 0 my $default = delete $opts{default};
805 0 my $val = $self->uri(%opts, default => undef);
806  
807 0 require Mojo::URL;
808  
809 0 ▶ return Mojo::URL->new($val) if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 0 0 0
810 0 ▶ if ($had_default) {
Branch: 1 branch
BranchTrueFalseTotal
if ($had_default) 0 0 0
811 0 ▶ return $default if ref $default;
Branch: 1 branch
BranchTrueFalseTotal
if ref $default 0 0 0
812 0 return Mojo::URL->new($default);
813 }
814 0 croak 'No value for URI';
815 ▶ } elsif ($as eq 'Data::URIID::Result' && defined($opts{extractor})) {
Condition0%0/3
$as eq "Data::URIID::Result" and defined $opts{"extractor"}
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "Data::URIID::Result" and defined $opts{"extractor"}
$as eq "Data::URIID::Result" defined $opts{"extractor"}
Truth table0%0/3
A and B
A= $as eq "Data::URIID::Result"B= defined $opts{"extractor"}
ABresult
0X0
100
111
816 0 return $opts{extractor}->lookup($self->type->uuid => $self->id);
817 ▶ } elsif ($as eq 'Data::URIID::Service' && defined($opts{extractor})) {
Condition0%0/3
$as eq "Data::URIID::Service" and defined $opts{"extractor"}
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "Data::URIID::Service" and defined $opts{"extractor"}
$as eq "Data::URIID::Service" defined $opts{"extractor"}
Truth table0%0/3
A and B
A= $as eq "Data::URIID::Service"B= defined $opts{"extractor"}
ABresult
0X0
100
111
818 0 return $opts{extractor}->service($self->uuid);
819 ▶ } elsif ($as eq 'SIRTX::Datecode' && eval {
Condition0%0/3
$as eq "SIRTX::Datecode" and eval { do { require SIRTX::Datecode; "SIRTX::Datecode"->VERSION(v0.03); 1 } }
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "SIRTX::Datecode" and eval { do { require SIRTX::Datecode; "SIRTX::Datecode"->VERSION(v0.03); 1 } }
$as eq "SIRTX::Datecode" eval { do { require SIRTX::Datecode; "SIRTX::Datecode"->VERSION(v0.03); 1 } }
Truth table0%0/3
A and B
A= $as eq "SIRTX::Datecode"B= eval { do { require SIRTX::Datecode; "SIRTX::Datecode"->VERSION(v0.03); 1 } }
ABresult
0X0
100
111
820 0 require SIRTX::Datecode;
821 0 SIRTX::Datecode->VERSION(v0.03);
822 0 1;
823 }) {
824 0 return SIRTX::Datecode->new(from => $self);
825 ▶ } elsif ($as eq 'Data::URIID::Colour' && eval {
Condition0%0/3
$as eq "Data::URIID::Colour" and eval { do { require Data::URIID; require Data::URIID::Colour; "Data::URIID::Colour"->VERSION(v0.14); 1 } }
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "Data::URIID::Colour" and eval { do { require Data::URIID; require Data::URIID::Colour; "Data::URIID::Colour"->VERSION(v0.14); 1 } }
$as eq "Data::URIID::Colour" eval { do { require Data::URIID; require Data::URIID::Colour; "Data::URIID::Colour"->VERSION(v0.14); 1 } }
Truth table0%0/3
A and B
A= $as eq "Data::URIID::Colour"B= eval { do { require Data::URIID; require Data::URIID::Colour; "Data::URIID::Colour"->VERSION(v0.14); 1 } }
ABresult
0X0
100
111
826 0 require Data::URIID;
827 0 require Data::URIID::Colour;
828 0 Data::URIID::Colour->VERSION(v0.14);
829 0 1;
830 }) {
831 0 return Data::URIID::Colour->new(from => $self, %opts{qw(extractor db fii store)});
832 ▶ } elsif ($as eq 'Data::TagDB::Tag' && defined($opts{db})) {
Condition0%0/3
$as eq "Data::TagDB::Tag" and defined $opts{"db"}
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "Data::TagDB::Tag" and defined $opts{"db"}
$as eq "Data::TagDB::Tag" defined $opts{"db"}
Truth table0%0/3
A and B
A= $as eq "Data::TagDB::Tag"B= defined $opts{"db"}
ABresult
0X0
100
111
833 0 ▶ if ($opts{autocreate}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'autocreate'}) { } 0 0 0
834 0 return $opts{db}->create_tag($self);
835 } else {
836 0 return $opts{db}->tag_by_id($self);
837 }
838 ▶ } elsif ($as eq 'File::FStore::File' && defined($opts{store})) {
Condition0%0/3
$as eq "File::FStore::File" and defined $opts{"store"}
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "File::FStore::File" and defined $opts{"store"}
$as eq "File::FStore::File" defined $opts{"store"}
Truth table0%0/3
A and B
A= $as eq "File::FStore::File"B= defined $opts{"store"}
ABresult
0X0
100
111
839 0 return scalar($opts{store}->query(ise => $self));
840 ▶ } elsif ($as eq 'Business::ISBN' && $self->type->eq('gtin')) {
Condition0%0/3
$as eq "Business::ISBN" and $self->type->eq("gtin")
!ll&&!rl&&r
000
MC/DC0%0/2
$as eq "Business::ISBN" and $self->type->eq("gtin")
$as eq "Business::ISBN" $self->type->eq("gtin")
Truth table0%0/3
A and B
A= $as eq "Business::ISBN"B= $self->type->eq("gtin")
ABresult
0X0
100
111
841 0 require Business::ISBN;
842 0 my $val = Business::ISBN->new($self->id);
843 0 ▶ return $val if defined($val) && $val->is_valid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val and $val->is_valid 0 0 0
Condition0%0/3
defined $val and $val->is_valid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and $val->is_valid
defined $val $val->is_valid
Truth table0%0/3
A and B
A= defined $valB= $val->is_valid
ABresult
0X0
100
111
844 ▶ } elsif ($as =~ /^Math::Big(?:Int|Rat|Float)\z/ &&
Condition0%0/6
$as =~ /^Math::Big(?:Int|Rat|Float)\z/u and defined $self->request("default", undef, "no_defaults", 1) and eval { do { $self->generator->eq("53863a15-68d4-448d-bd69-a9b19289a191") or $self->generator->eq("e8aa9e01-8d37-4b4b-8899-42ca0a2a906f") } }
!ll&&!rl&&r
000
$as =~ /^Math::Big(?:Int|Rat|Float)\z/u and defined $self->request("default", undef, "no_defaults", 1)
!ll&&!rl&&r
000
MC/DC0%0/3
$as =~ /^Math::Big(?:Int|Rat|Float)\z/u and defined $self->request("default", undef, "no_defaults", 1) and eval { do { $self->generator->eq("53863a15-68d4-448d-bd69-a9b19289a191") or $self->generator->eq("e8aa9e01-8d37-4b4b-8899-42ca0a2a906f") } }
$as =~ /^Math::Big(?:Int|Rat|Float)\z/u defined $self->request("default", undef, "no_defaults", 1) eval { do { $self->generator->eq("53863a15-68d4-448d-bd69-a9b19289a191") or $self->generator->eq("e8aa9e01-8d37-4b4b-8899-42ca0a2a906f") } }
Truth table0%0/4
A and B and C
A= $as =~ /^Math::Big(?:Int|Rat|Float)\z/uB= defined $self->request("default", undef, "no_defaults", 1)C= eval { do { $self->generator->eq("53863a15-68d4-448d-bd69-a9b19289a191") or $self->generator->eq("e8aa9e01-8d37-4b4b-8899-42ca0a2a906f") } }
ABCresult
0XX0
10X0
1100
1111
845 0 ▶ defined($self->request(default => undef, no_defaults => 1)) && eval { $self->generator->eq('53863a15-68d4-448d-bd69-a9b19289a191') || $self->generator->eq('e8aa9e01-8d37-4b4b-8899-42ca0a2a906f')}) {
Condition0%0/3
$self->generator->eq('53863a15-68d4-448d-bd69-a9b19289a191') || $self->generator->eq('e8aa9e01-8d37-4b4b-8899-42ca0a2a906f')
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->generator->eq('53863a15-68d4-448d-bd69-a9b19289a191') || $self->generator->eq('e8aa9e01-8d37-4b4b-8899-42ca0a2a906f')
$self->generator->eq('53863a15-68d4-448d-bd69-a9b19289a191') $self->generator->eq('e8aa9e01-8d37-4b4b-8899-42ca0a2a906f')
Truth table0%0/3
A || B
A= $self->generator->eq('53863a15-68d4-448d-bd69-a9b19289a191')B= $self->generator->eq('e8aa9e01-8d37-4b4b-8899-42ca0a2a906f')
ABresult
1X1
011
000
846 0 ▶ if ($as eq 'Math::BigInt') {
Branch: 3 branches
BranchTrueFalseTotal
if ($as eq 'Math::BigInt') { } 0 0 0
elsif ($as eq 'Math::BigRat') { } 0 0 0
elsif ($as eq 'Math::BigFloat') { } 0 0 0
847 # Already loaded.
848 0 return Math::BigInt->new($self->request);
849 } elsif ($as eq 'Math::BigRat') {
850 0 require Math::BigRat;
851 0 state $x = Math::BigRat->import;
852 0 return Math::BigRat->new($self->request);
853 } elsif ($as eq 'Math::BigFloat') {
854 0 require Math::BigFloat;
855 0 state $x = Math::BigFloat->import;
856 0 return Math::BigFloat->new($self->request);
857 } else {
858 0 croak 'BUG';
859 }
860 } elsif ($as =~ /^Convert::Color(?:::.+)?\z/) {
861 0 ▶ if ($as eq 'Convert::Color' || $as eq 'Convert::Color::X11') {
Branch: 1 branch
BranchTrueFalseTotal
if ($as eq "Convert::Color" or $as eq "Convert::Color::X11") 0 0 0
Condition0%0/3
$as eq "Convert::Color" or $as eq "Convert::Color::X11"
l!l&&r!l&&!r
000
MC/DC0%0/2
$as eq "Convert::Color" or $as eq "Convert::Color::X11"
$as eq "Convert::Color" $as eq "Convert::Color::X11"
Truth table0%0/3
A or B
A= $as eq "Convert::Color"B= $as eq "Convert::Color::X11"
ABresult
1X1
011
000
862 0 my $x11_name = $self->as(state $type = Data::Identifier->new(uuid => '135032f7-cc60-46ee-8f64-1724c2a56fa2')->register, default => undef);
863 0 ▶ if (defined $x11_name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $x11_name) 0 0 0
864 0 require Convert::Color::X11;
865 0 return Convert::Color::X11->new($x11_name);
866 }
867 }
868 0 return $self->as('Data::URIID::Colour')->as($as, %opts);
869 } elsif (defined(my $r = $perl_package_registrations{$as})) {
870 0 ▶ if (defined(my $from_identifier = $r->{from_identifier})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $from_identifier = $r->{"from_identifier"})) 0 0 0
871 0 my $so = $opts{so};
872 0 my $res;
873  
874 0 ▶ if (ref($so) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $so eq "HASH") 0 0 0
875 0 require Data::Identifier::Interface::Subobjects;
876 0 $so = Data::Identifier::Interface::Subobjects->so_new->so_attach(%{$so});
877 }
878  
879 0 $res = $from_identifier->($as, $self, %opts{qw(autocreate)}, so => $so);
880 0 ▶ croak 'Invalid return from external converter function' unless $res->isa($as);
Branch: 1 branch
BranchTrueFalseTotal
unless $res->isa($as) 0 0 0
881 0 return $res;
882 }
883 }
884  
885 0 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
886 0 croak 'Unknown/Unsupported as: '.$as;
887 }
888  
889  
890 87 ▶sub eq {
Subroutine eq: called CC=9 SCAR=23.1
Pod documented
891 87 my ($self, $other) = @_;
892  
893 87 foreach my $e ($self, $other) {
894 174 ▶ if (defined($e) && !scalar(eval {$e->isa(__PACKAGE__)})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } }) 31 143 174
Condition66%2/3
defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } }
!ll&&!rl&&r
014331
MC/DC50%1/2
defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } }
defined $e not scalar eval { do { $e->isa(__PACKAGE__) } }
Truth table66%2/3
A and not(B)
A= defined $eB= not scalar eval { do { $e->isa(__PACKAGE__) } }
ABresult
0X0
100
111
895 31 ▶ if (defined $well_known{$e}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $well_known{$e}) { } 20 11 31
896 20 $e = $well_known{$e}
897 } else {
898 11 $e = Data::Identifier->new(from => $e);
899 }
900 }
901 }
902  
903 87 ▶ if (defined($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self) { } 87 0 87
904 87 ▶ return undef unless defined $other;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 87 87
905 87 ▶ return 1 if $self == $other;
Branch: 1 branch
BranchTrueFalseTotal
if $self == $other 57 30 87
906 30 ▶ if ($self->type->eq($other->type)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->type->eq($other->type)) { } 30 0 30
907 30 return $self->id eq $other->id;
908 } else {
909 0 return scalar(eval {$self->ise eq $other->ise});
910 }
911 } else {
912 0 return !defined($other);
913 }
914 }
915  
916  
917 0 ▶sub cmp {
Subroutine cmp: not called CC=13 SCAR=52.0
Pod documented
918 0 my ($self, $other) = @_;
919  
920 0 foreach my $e ($self, $other) {
921 0 ▶ if (defined($e) && !scalar(eval {$e->isa(__PACKAGE__)})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } }) 0 0 0
Condition0%0/3
defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } }
!ll&&!rl&&r
000
MC/DC0%0/2
defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } }
defined $e not scalar eval { do { $e->isa(__PACKAGE__) } }
Truth table0%0/3
A and not(B)
A= defined $eB= not scalar eval { do { $e->isa(__PACKAGE__) } }
ABresult
0X0
100
111
922 0 ▶ if (defined $well_known{$e}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $well_known{$e}) { } 0 0 0
923 0 $e = $well_known{$e}
924 } else {
925 0 $e = Data::Identifier->new(from => $e);
926 }
927 }
928 }
929  
930 0 ▶ if (defined($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self) { } 0 0 0
931 0 ▶ return undef unless defined $other;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 0 0
932 0 ▶ return 0 if $self == $other;
Branch: 1 branch
BranchTrueFalseTotal
if $self == $other 0 0 0
933 0 ▶ if ((my $r = $self->type->cmp($other->type)) != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $r = $self->type->cmp($other->type)) != 0) 0 0 0
934 0 ▶ return 0 if eval {$self->ise eq $other->ise};
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $self->ise eq $other->ise } } 0 0 0
935 0 return $r;
936 }
937  
938 {
939 0 my $self_id = $self->id;
940 0 my $other_id = $other->id;
941  
942 0 ▶ if ((my ($sa, $sb) = $self_id =~ /^([^0-9]*)([0-9]+)\z/) && (my ($oa, $ob) = $other_id =~ /^([^0-9]*)([0-9]+)\z/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $self_id =~ /^([^0-9]*)([0-9]+)\z/u and () = $other_id =~ /^([^0-9]*)([0-9]+)\z/u) 0 0 0
Condition0%0/3
() = $self_id =~ /^([^0-9]*)([0-9]+)\z/u and () = $other_id =~ /^([^0-9]*)([0-9]+)\z/u
!ll&&!rl&&r
000
MC/DC0%0/2
() = $self_id =~ /^([^0-9]*)([0-9]+)\z/u and () = $other_id =~ /^([^0-9]*)([0-9]+)\z/u
() = $self_id =~ /^([^0-9]*)([0-9]+)\z/u () = $other_id =~ /^([^0-9]*)([0-9]+)\z/u
Truth table0%0/3
A and B
A= () = $self_id =~ /^([^0-9]*)([0-9]+)\z/uB= () = $other_id =~ /^([^0-9]*)([0-9]+)\z/u
ABresult
0X0
100
111
943 0 my $r = $sa cmp $oa;
944 0 ▶ return $r if $r;
Branch: 1 branch
BranchTrueFalseTotal
if $r 0 0 0
945 0 return $sb <=> $ob;
946 }
947  
948 0 return $self_id cmp $other_id;
949 }
950 } else {
951 0 return !defined($other);
952 }
953 }
954  
955  
956 20 ▶sub null_to_undef {
Subroutine null_to_undef: called CC=5 SCAR=16.8
Pod documented
957 20 my ($self, @opts) = @_;
958  
959 20 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 20 20
960  
961 20 ▶ return undef unless defined $self;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self 0 20 20
962  
963 20 ▶ unless (eval {$self->isa(__PACKAGE__)}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $self->isa(__PACKAGE__) } }) 0 20 20
964 0 $self = __PACKAGE__->new(from => $self);
965 }
966  
967 20 ▶ return undef if $self->eq('null');
Branch: 1 branch
BranchTrueFalseTotal
if $self->eq("null") 8 12 20
968  
969 12 return $self;
970 }
971  
972  
973 10 ▶sub is_null {
Subroutine is_null: called CC=2 SCAR=7.1
Pod documented
974 10 my ($self, @opts) = @_;
975  
976 10 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 10 10
977  
978 10 return !defined Data::Identifier::null_to_undef($self);
979 }
980  
981  
982 #@returns __PACKAGE__
983 67 ▶sub namespace {
Subroutine namespace: called CC=4 SCAR=16.6
Pod documented
984 67 my ($self, %opts) = @_;
985 67 my $has_default = exists $opts{default};
986 67 my $default = delete $opts{default};
987  
988 67 delete $opts{no_defaults};
989  
990 67 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 67 67
991  
992 67 ▶ return $self->{namespace} if defined $self->{namespace};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"namespace"} 67 0 67
993  
994 0 ▶ return $default if $has_default;
Branch: 1 branch
BranchTrueFalseTotal
if $has_default 0 0 0
995  
996 0 croak 'No namespace';
997 }
998  
999  
1000 #@returns __PACKAGE__
1001 0 ▶sub generator {
Subroutine generator: not called CC=4 SCAR=30.0
Pod documented
1002 0 my ($self, %opts) = @_;
1003 0 my $has_default = exists $opts{default};
1004 0 my $default = delete $opts{default};
1005  
1006 0 delete $opts{no_defaults};
1007  
1008 0 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 0 0
1009  
1010 0 ▶ return $self->{generator} if defined $self->{generator};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"generator"} 0 0 0
1011  
1012 0 ▶ return $default if $has_default;
Branch: 1 branch
BranchTrueFalseTotal
if $has_default 0 0 0
1013  
1014 0 croak 'No generator';
1015 }
1016  
1017  
1018 0 ▶sub request {
Subroutine request: not called CC=4 SCAR=30.0
Pod documented
1019 0 my ($self, %opts) = @_;
1020 0 my $has_default = exists $opts{default};
1021 0 my $default = delete $opts{default};
1022  
1023 0 delete $opts{no_defaults};
1024  
1025 0 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 0 0
1026  
1027 0 ▶ return $self->{request} if defined $self->{request};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"request"} 0 0 0
1028  
1029 0 ▶ return $default if $has_default;
Branch: 1 branch
BranchTrueFalseTotal
if $has_default 0 0 0
1030  
1031 0 croak 'No request';
1032 }
1033  
1034  
1035 #@returns __PACKAGE__
1036 2164 ▶sub register {
Subroutine register: called CC=6 SCAR=18.0
Pod documented
1037 2164 my ($self) = @_;
1038 2164 $registered{$self->{type}->uuid}{$self->{id}} = $self;
1039  
1040 2164 foreach my $type_name (qw(uuid oid uri sid)) {
1041 8656 ▶ my $f = $self->can($type_name) || next;
Condition50%1/2
$self->can($type_name) || (next)
l!l
86560
MC/DC0%0/1
$self->can($type_name) || (next)
$self->can($type_name)
Truth table50%1/2
A
A= $self->can($type_name)
Aresult
11
00
1042 8656 ▶ my $v = $self->$f(default => undef) // next;
Condition100%2/2
$self->$f("default", undef) // (next)
l!l
73671289
MC/DC100%1/1
$self->$f("default", undef) // (next)
$self->$f("default", undef)
Truth table100%2/2
A
A= $self->$f("default", undef)
Aresult
11
00
1043 7367 $registered{$well_known{$type_name}->uuid}{$v} = $self;
1044 }
1045  
1046 2164 foreach my $extra (keys %{$self->{id_cache}}) {
1047 5625 ▶ my $v = $self->{id_cache}{$extra} // next;
Condition50%1/2
$self->{"id_cache"}{$extra} // (next)
l!l
56250
MC/DC0%0/1
$self->{"id_cache"}{$extra} // (next)
$self->{"id_cache"}{$extra}
Truth table50%1/2
A
A= $self->{"id_cache"}{$extra}
Aresult
11
00
1048 5625 $registered{$extra}{$v} = $self;
1049 }
1050  
1051 2164 return $self;
1052 }
1053  
1054  
1055  
1056 956 ▶sub displayname {
Subroutine displayname: called CC=8 SCAR=22.0
Pod documented
1057 956 my ($self, %opts) = @_;
1058  
1059 956 ▶ if (defined(my $displayname = $self->{displayname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $displayname = $self->{"displayname"})) 900 56 956
1060 900 ▶ $displayname = $self->$displayname() if ref $displayname;
Branch: 1 branch
BranchTrueFalseTotal
if ref $displayname 0 900 900
1061  
1062 # recheck and return as any of the above conversions could result in $displayname becoming invalid.
1063 900 ▶ return $displayname if defined($displayname) && length($displayname);
Branch: 1 branch
BranchTrueFalseTotal
if defined $displayname and length $displayname 900 0 900
Condition33%1/3
defined $displayname and length $displayname
!ll&&!rl&&r
00900
MC/DC0%0/2
defined $displayname and length $displayname
defined $displayname length $displayname
Truth table33%1/3
A and B
A= defined $displaynameB= length $displayname
ABresult
0X0
100
111
1064 }
1065  
1066 56 ▶ if (defined(my $tagname = $self->tagname(default => undef, no_defaults => 1))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $tagname = $self->tagname("default", undef, "no_defaults", 1))) 20 36 56
1067 20 return $tagname;
1068 }
1069  
1070 36 ▶ return $self->id.'' unless $opts{no_defaults}; # force stringification.
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"no_defaults"} 34 2 36
1071 2 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 2 0 2
1072 0 croak 'No value for displayname';
1073 }
1074  
1075  
1076 0 ▶sub displaycolour {
Subroutine displaycolour: not called CC=6 SCAR=37.4
Pod documented
1077 0 my ($self, %opts) = @_;
1078  
1079 0 ▶ if (defined(my $value = $self->{displaycolour})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = $self->{"displaycolour"})) 0 0 0
1080 0 ▶ $value = $self->$value() if ref($value) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "CODE" 0 0 0
1081  
1082 # recheck and return as any of the above conversions could result in $displayname becoming invalid.
1083 0 ▶ return $value if defined($value) && length($value);
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and length $value 0 0 0
Condition0%0/3
defined $value and length $value
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value and length $value
defined $value length $value
Truth table0%0/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
1084 }
1085  
1086 0 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
1087 0 croak 'No value found';
1088 }
1089 0 ▶sub icontext {
Subroutine icontext: not called CC=6 SCAR=37.4
Pod documented
1090 0 my ($self, %opts) = @_;
1091  
1092 0 ▶ if (defined(my $value = $self->{icontext})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = $self->{"icontext"})) 0 0 0
1093 0 ▶ $value = $self->$value() if ref $value;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 0 0 0
1094  
1095 # recheck and return as any of the above conversions could result in $displayname becoming invalid.
1096 0 ▶ return $value if defined($value) && length($value);
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and length $value 0 0 0
Condition0%0/3
defined $value and length $value
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value and length $value
defined $value length $value
Truth table0%0/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
1097 }
1098  
1099 0 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
1100 0 croak 'No value found';
1101 }
1102 0 ▶sub description {
Subroutine description: not called CC=6 SCAR=37.4
Pod documented
1103 0 my ($self, %opts) = @_;
1104  
1105 0 ▶ if (defined(my $value = $self->{description})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = $self->{"description"})) 0 0 0
1106 0 ▶ $value = $self->$value() if ref $value;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 0 0 0
1107  
1108 # recheck and return as any of the above conversions could result in $displayname becoming invalid.
1109 0 ▶ return $value if defined($value) && length($value);
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and length $value 0 0 0
Condition0%0/3
defined $value and length $value
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value and length $value
defined $value length $value
Truth table0%0/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
1110 }
1111  
1112 0 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 0 0 0
1113 0 croak 'No value found';
1114 }
1115  
1116  
1117 56 ▶sub tagname {
Subroutine tagname: called CC=6 SCAR=19.2
Pod documented
1118 56 my ($self, %opts) = @_;
1119 56 my $had_default = exists $opts{default};
1120 56 my $default = delete $opts{default};
1121 56 my $list = delete $opts{list};
1122  
1123 56 delete $opts{no_defaults}; # for compatibility.
1124  
1125 56 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 56 56
1126  
1127 56 ▶ if (defined(my $tagname = $self->{tagname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $tagname = $self->{"tagname"})) 20 36 56
1128 0 ▶ return @{$tagname} if $list;
Branch: 1 branch
BranchTrueFalseTotal
if $list 0 20 20
1129  
1130 20 return $tagname->[0];
1131 }
1132  
1133 36 ▶ if ($had_default) {
Branch: 1 branch
BranchTrueFalseTotal
if ($had_default) 36 0 36
1134 0 ▶ return @{$default} if $list;
Branch: 1 branch
BranchTrueFalseTotal
if $list 0 36 36
1135 36 return $default;
1136 }
1137 0 croak 'No value for tagname found';
1138 }
1139  
1140 # ---- Private helpers ----
1141  
1142 19 ▶sub import {
Subroutine import: called CC=11 SCAR=46.2
1143 19 my ($pkg, $opts) = @_;
1144 19 ▶ return unless defined $opts;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts 19 0 19
1145 0 ▶ croak 'Bad options' unless ref($opts) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $opts eq "HASH" 0 0 0
1146  
1147 0 ▶ if (defined(my $disable = $opts->{disable})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $disable = $opts->{"disable"})) 0 0 0
1148 0 ▶ $disable = [split /\s*,\s*/, $disable] unless ref $disable;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $disable 0 0 0
1149 0 foreach my $to_disable (@{$disable}) {
1150 0 ▶ if ($to_disable eq 'oid') {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_disable eq 'oid') { } 0 0 0
1151 0 $enabled_oid = undef;
1152 0 undef *oid;
1153 } else {
1154 0 croak 'Unknown feature: '.$to_disable;
1155 }
1156 }
1157 }
1158  
1159 0 ▶ if (defined(my $allow_use = $opts->{allow_use})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $allow_use = $opts->{"allow_use"})) 0 0 0
1160 0 ▶ $allow_use = [split /\s*,\s*/, $allow_use] unless ref $allow_use;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $allow_use 0 0 0
1161 0 foreach my $to_use (@{$allow_use}) {
1162 0 ▶ if ($to_use eq 'Data::URIID::Colour') {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_use eq "Data::URIID::Colour") 0 0 0
1163 0 require Data::URIID::Colour;
1164 }
1165 }
1166 }
1167 }
1168  
1169 91 ▶sub _generate {
Subroutine _generate: called CC=8 SCAR=21.3
1170 91 my ($self) = @_;
1171 91 ▶ unless (exists $self->{_generate}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_generate"}) 79 12 91
1172 79 my __PACKAGE__ $type = $self->type;
1173  
1174 79 ▶ if (defined(my $generate = $type->{generate})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $generate = $type->{"generate"})) 67 12 79
1175 67 ▶ unless (ref $generate) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $generate) 67 0 67
1176 67 $self->{generate} = $generate = {style => $generate};
1177 }
1178  
1179 67 ▶ $self->{id_cache} //= {};
Condition50%1/2
$self->{"id_cache"} //= {}
l!l
067
MC/DC0%0/1
$self->{"id_cache"} //= {}
$self->{"id_cache"}
Truth table50%1/2
A
A= $self->{"id_cache"}
Aresult
11
00
1180  
1181 67 ▶ if (defined(my __PACKAGE__ $ns = eval {$type->namespace->uuid})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my Data::Identifier $ns = eval { do { $type->namespace->uuid } })) 67 0 67
1182 67 my $style = $generate->{style};
1183 67 my $input;
1184  
1185 67 ▶ if ($style eq 'id-based') {
Branch: 1 branch
BranchTrueFalseTotal
if ($style eq 'id-based') { } 67 0 67
1186 67 $input = lc($self->id);
1187 } else {
1188 0 croak 'Unsupported generator style';
1189 }
1190  
1191 67 ▶ if (defined $input) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $input) 67 0 67
1192 67 require Data::Identifier::Generate;
1193 67 $self->{id_cache}{WK_UUID()} = Data::Identifier::Generate->_uuid_v5($ns, $input);
1194 }
1195 }
1196 }
1197 }
1198 91 $self->{_generate} = undef;
1199 }
1200  
1201 13 ▶sub _known_provider {
Subroutine _known_provider: called CC=5 SCAR=16.3
1202 13 my ($pkg, $class, %opts) = @_;
1203 13 ▶ croak 'Unsupported options passed' if scalar(keys %opts);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 13 13
1204  
1205 13 ▶ if ($class eq 'wellknown') {
Branch: 2 branches
BranchTrueFalseTotal
if ($class eq 'wellknown') { } 10 3 13
elsif ($class eq 'registered' or $class eq ':all') { } 3 0 3
1206 10 state $wellknown = do {
1207 8 my %hash = map{$_ => $_} values(%well_known), map {values %{$_}} values(%registered);
1208 8 [values %hash];
1209 };
1210  
1211 10 return ($wellknown, rawtype => __PACKAGE__);
1212 ▶ } elsif ($class eq 'registered' || $class eq ':all') {
Condition66%2/3
$class eq "registered" or $class eq ":all"
l!l&&r!l&&!r
210
MC/DC0%0/2
$class eq "registered" or $class eq ":all"
$class eq "registered" $class eq ":all"
Truth table66%2/3
A or B
A= $class eq "registered"B= $class eq ":all"
ABresult
1X1
011
000
1213 3 my %hash = map{$_ => $_} values(%well_known), map {values %{$_}} values(%registered);
1214 3 return ([values %hash], rawtype => __PACKAGE__);
1215 }
1216  
1217 0 croak 'Unsupported class';
1218 }
1219  
1220 #@returns __PACKAGE__
1221 470 ▶sub _add_tagnames {
Subroutine _add_tagnames: called CC=2 SCAR=6.9
1222 470 my ($self, @tagnames) = @_;
1223 470 ▶ my %tagnames = map {$_ => undef} grep {defined} @{$self->{tagname} //= []}, @tagnames;
Condition100%2/2
$self->{"tagname"} //= []
l!l
45425
MC/DC100%1/1
$self->{"tagname"} //= []
$self->{"tagname"}
Truth table100%2/2
A
A= $self->{"tagname"}
Aresult
11
00
1224 470 @{$self->{tagname}} = keys %tagnames;
1225 470 return $self;
1226 }
1227  
1228 # Interface method for Data::Identifier::Util's register_package() ONLY.
1229 0 ▶sub _get_perl_package_registrations {
Subroutine _get_perl_package_registrations: not called CC=1 SCAR=6.9
1230 0 return \%perl_package_registrations;
1231 }
1232  
1233 8 1;
1234  
1235 __END__
↑ Summary Identifier/Cloudlet.pm »