Identifier.pm

filter: Statementstmt 58.6% 365 / 622 Branchbran 44.2% 185 / 418 Conditioncond 39.5% 127 / 321 MC/DCmcdc 16.5% 31 / 187 Subroutinesub 76.1% 32 / 42 Podpod 100% 23 / 23 totaltotal 47.3% 763 / 1613 CC 321 SCAR 71.5
CC
321
Cov
50%
new
2993.2
as
1687.3
cmp
182.0
CRAP 1276.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 13 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 13 ▶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 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 13 ▶use Math::BigInt lib => 'GMP';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 13 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 13 our $VERSION = v0.39.02;
23  
24 13 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
25 13 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 13 };
36  
37 13 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
38 13 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 13 };
62  
63 # Features:
64 13 my $enabled_oid = 1;
65  
66 13 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 13 my %uuid_org_to_uuid = map {$uuid_to_uriid_org{$_} => $_} keys %uuid_to_uriid_org;
76  
77 13 my $well_known_uuid = __PACKAGE__->new(ise => WK_UUID, validate => RE_UUID);
78  
79 13 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 13 my %registered;
103  
104 13 $_->register foreach values %well_known;
105  
106 13 my %perl_package_registrations;
107  
108 # Refill with namespaces:
109 {
110 13 my %ns = (
111 wd => NS_WD,
112 fc => NS_FC,
113 gtin => NS_GTIN,
114 unicodecp => NS_UNICODE_CP,
115 );
116  
117 13 foreach my $wk (keys %ns) {
118 52 ▶ $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
0520
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 13 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 13 foreach my $ise (keys %wk_sids) {
168 481 my $identifier = __PACKAGE__->new(ise => $ise);
169 481 ▶ $identifier->{id_cache} //= {};
Condition100%2/2
$identifier->{"id_cache"} //= {}
l!l
117364
MC/DC100%1/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table100%2/2
A
A= $identifier->{"id_cache"}
Aresult
11
00
170 481 ▶ $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
04810
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 481 $identifier->register; # re-register
172 }
173 }
174  
175 # Refill with snis:
176 {
177 13 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 13 foreach my $ise (keys %wk_snis) {
190 117 my $identifier = __PACKAGE__->new(ise => $ise);
191 117 ▶ $identifier->{id_cache} //= {};
Condition50%1/2
$identifier->{"id_cache"} //= {}
l!l
1170
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table50%1/2
A
A= $identifier->{"id_cache"}
Aresult
11
00
192 117 ▶ $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
01170
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 117 $identifier->register; # re-register
194 }
195 }
196  
197 # Update NULL:
198 {
199 13 my $identifier = __PACKAGE__->new(uuid => WK_NULL);
200 13 ▶ $identifier->{id_cache} //= {};
Condition50%1/2
$identifier->{"id_cache"} //= {}
l!l
130
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table50%1/2
A
A= $identifier->{"id_cache"}
Aresult
11
00
201 13 foreach my $type (WK_HDI, WK_CHAT0W) {
202 26 ▶ $identifier->{id_cache}->{$type} //= 0;
Condition50%1/2
$identifier->{"id_cache"}{$type} //= 0
l!l
026
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 13 $identifier->register;
205 }
206  
207 # Some extra tags such as namespaces:
208 13 foreach my $ise (NS_WD, NS_INT, NS_DATE) {
209 39 my $identifier = __PACKAGE__->new(ise => $ise);
210 39 $identifier->register; # re-register
211 }
212  
213 # Refill with tagnames
214 {
215 13 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 13 foreach my $ise (keys %tagnames) {
276 728 my $identifier = __PACKAGE__->new(ise => $ise);
277 728 ▶ $identifier->{tagname} //= [$tagnames{$ise}];
Condition50%1/2
$identifier->{"tagname"} //= [$tagnames{$ise}]
l!l
0728
MC/DC0%0/1
$identifier->{"tagname"} //= [$tagnames{$ise}]
$identifier->{"tagname"}
Truth table50%1/2
A
A= $identifier->{"tagname"}
Aresult
11
00
278 728 $identifier->register; # re-register
279 }
280 }
281  
282 {
283 # ISE -> namespace
284 13 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 13 my %namespaces_sint = (
290 '2bffc55d-7380-454e-bd53-c5acd525d692' => '744eaf4e-ae93-44d8-9ab5-744105222da6', # roaraudio-error-number: roaraudio-error-namespace
291 );
292 13 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 13 foreach my $ise (keys %namespaces_uint) {
298 39 my $identifier = __PACKAGE__->new(ise => $ise);
299 39 ▶ $identifier->{namespace} //= __PACKAGE__->new(ise => $namespaces_uint{$ise});
Condition33%1/3
$identifier->{"namespace"} //= __PACKAGE__->new("ise", $namespaces_uint{$ise})
l!l&&r!l&&!r
0390
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 39 ▶ $identifier->{validate} //= RE_UINT;
Condition50%1/2
$identifier->{"validate"} //= qr/^(?:0|[1-9][0-9]*)\z/u
l!l
039
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 39 ▶ $identifier->{generate} //= 'id-based';
Condition50%1/2
$identifier->{"generate"} //= "id-based"
l!l
039
MC/DC0%0/1
$identifier->{"generate"} //= "id-based"
$identifier->{"generate"}
Truth table50%1/2
A
A= $identifier->{"generate"}
Aresult
11
00
302 39 $identifier->register; # re-register
303 }
304  
305 13 foreach my $ise (keys %namespaces_sint) {
306 13 my $identifier = __PACKAGE__->new(ise => $ise);
307 13 ▶ $identifier->{namespace} //= __PACKAGE__->new(ise => $namespaces_sint{$ise});
Condition33%1/3
$identifier->{"namespace"} //= __PACKAGE__->new("ise", $namespaces_sint{$ise})
l!l&&r!l&&!r
0130
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 13 ▶ $identifier->{validate} //= RE_SINT;
Condition50%1/2
$identifier->{"validate"} //= qr/^(?:0|-?[1-9][0-9]*)\z/u
l!l
013
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 13 ▶ $identifier->{generate} //= 'id-based';
Condition50%1/2
$identifier->{"generate"} //= "id-based"
l!l
013
MC/DC0%0/1
$identifier->{"generate"} //= "id-based"
$identifier->{"generate"}
Truth table50%1/2
A
A= $identifier->{"generate"}
Aresult
11
00
310 13 $identifier->register; # re-register
311 }
312  
313 13 foreach my $ise (keys %namespaces_simple_tag) {
314 26 my $identifier = __PACKAGE__->new(ise => $ise);
315 26 ▶ $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
0260
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 26 ▶ $identifier->{validate} //= RE_SIMPLE_TAG;
Condition50%1/2
$identifier->{"validate"} //= qr/^[^\p{upper case}\s:]+\z/u
l!l
026
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 26 ▶ $identifier->{generate} //= 'id-based';
Condition50%1/2
$identifier->{"generate"} //= "id-based"
l!l
026
MC/DC0%0/1
$identifier->{"generate"} //= "id-based"
$identifier->{"generate"}
Truth table50%1/2
A
A= $identifier->{"generate"}
Aresult
11
00
318 26 $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 13 __PACKAGE__->_known_provider('wellknown');
326  
327  
328 3399 ▶sub new {
Subroutine new: called CC=108 SCAR=80.0
Pod documented
329 3399 my ($pkg, $type, $id, %opts) = @_;
330 3399 my $self = bless {};
331  
332 3399 ▶ croak 'No type given' unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 3399 3399
333 3399 ▶ croak 'No id given' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 3399 3399
334  
335 3399 ▶ if (!ref($type) && $type eq 'from') {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $type and $type eq "from") 236 3163 3399
Condition100%3/3
not ref $type and $type eq "from"
!ll&&!rl&&r
10272136236
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 236 ▶ if (ref($id)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $id) { } 42 194 236
337 42 my $from = $id;
338  
339 42 ▶ if ($from->isa('Convert::Color')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from->isa("Convert::Color")) 0 42 42
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 42 ▶ if ($from->isa('Data::Identifier')) {
Branch: 12 branches
BranchTrueFalseTotal
if ($from->isa('Data::Identifier')) { } 42 0 42
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 42 ▶ if (scalar(keys %opts)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %opts) { } 0 42 42
371 0 $type = $from->type;
372 0 $id = $from->id;
373 } else {
374 42 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 194 $type = 'ise';
456 }
457 }
458  
459 3357 ▶ if (!ref($type) && $type eq 'ise') {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $type and $type eq "ise") 1780 1577 3357
Condition100%3/3
not ref $type and $type eq "ise"
!ll&&!rl&&r
10275501780
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 1780 ▶ croak 'Undefined identifier but type is ISE' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 1780 1780
461  
462 1780 ▶ 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) { } 1760 20 1780
elsif ($id =~ /^[0-2](?:\.(?:0|[1-9][0-9]*))+\z/u) { } 0 20 20
elsif ($id =~ /^[a-zA-Z][a-zA-Z0-9\+\.\-]+:/u) { } 20 0 20
463 1760 $type = $well_known_uuid;
464  
465 # For bootstrap only.
466 1760 ▶ 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") 13 1747 1760
Condition66%2/3
not defined $type and $id eq "8be115d2-dc2f-4a98-91e1-a6e3075cbc31"
!ll&&!rl&&r
1747013
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 13 $self->{type} = $well_known_uuid = $type = $self;
468 13 $self->{id} = $id;
469 }
470 } elsif ($id =~ RE_OID) {
471 0 $type = 'oid';
472 } elsif ($id =~ RE_URI) {
473 20 $type = 'uri';
474 } else {
475 0 croak 'Not a valid ISE identifier';
476 }
477 }
478  
479 3357 ▶ unless (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $type) 570 2787 3357
480 570 ▶ 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 564 570
elsif ($type eq 'wellknown') { } 41 523 564
481 6 $type = $pkg->new(uuid => $type);
482 6 $type->register;
483 } elsif ($type eq 'wellknown') {
484 41 $self = $well_known{$id};
485 41 ▶ croak 'Unknown well-known' unless defined $self;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self 0 41 41
486 41 return $self;
487 } else {
488 523 $type = $well_known{$type};
489 }
490 529 ▶ croak 'Unknown type name' unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 529 529
491 }
492  
493 3316 ▶ croak 'Not a valid type' unless $type->isa(__PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
unless $type->isa(__PACKAGE__) 0 3316 3316
494  
495 # we normalise URIs first as they may then normalised again
496 3316 ▶ if ($type == ($well_known{uri} // 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == ($well_known{"uri"} // 0)) 248 3068 3316
Condition100%2/2
$well_known{"uri"} // 0
l!l
3108208
MC/DC100%1/1
$well_known{"uri"} // 0
$well_known{"uri"}
Truth table100%2/2
A
A= $well_known{"uri"}
Aresult
11
00
497 248 my $uri = $id.''; # force stringification
498  
499 248 ▶ 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 247 248
elsif ($uri =~ /^urn:oid:([0-2](?:\.(?:0|[1-9][0-9]*))+)\z/u) { } 0 247 247
elsif ($uri =~ /^urn:isbn:([0-9Xx-]+)\z/u and scalar eval { do { require Business::ISBN; 1 } }) { } 0 247 247
elsif ($uri =~ m[^https?://www\.wikidata\.org/entity/([QPL][1-9][0-9]*)\z]u) { } 0 247 247
elsif ($uri =~ m[^https?://doi\.org/(10\..+)\z]u) { } 0 247 247
elsif ($uri =~ m[^https?://uriid\.org/([^/]+)/[^/]+]u) { } 2 245 247
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
2470
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 3316 ▶ if ($type == ($well_known_uuid // 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type == ($well_known_uuid // 0)) { } 2832 484 3316
elsif ($type == ($well_known{'oid'} // 0)) { } 2 482 484
Condition50%1/2
$well_known_uuid // 0
l!l
33160
MC/DC0%0/1
$well_known_uuid // 0
$well_known_uuid
Truth table50%1/2
A
A= $well_known_uuid
Aresult
11
00
530 2832 $id = lc($id); # normalise
531 ▶ } elsif ($type == ($well_known{oid} // 0)) {
Condition50%1/2
$well_known{"oid"} // 0
l!l
4840
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 3316 ▶ if (defined($opts{displaycolour}) && !ref($opts{displaycolour})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"displaycolour"} and not ref $opts{"displaycolour"}) 0 3316 3316
Condition33%1/3
defined $opts{"displaycolour"} and not ref $opts{"displaycolour"}
!ll&&!rl&&r
331600
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 3316 ▶ if (defined(my $v = $registered{$type->uuid}{$id})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $v = $registered{$type->uuid}{$id})) 1219 2097 3316
547 1219 foreach my $key (qw(displayname displaycolour icontext description)) {
548 4876 ▶ next unless defined $opts{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{$key} 4819 57 4876
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 1219 ▶ if (defined(my $tagname = $opts{tagname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $tagname = $opts{"tagname"})) 0 1219 1219
552 0 ▶ $v->_add_tagnames(ref($tagname) ? @{$tagname} : ($tagname));
Branch: 1 branch
BranchTrueFalseTotal
ref $tagname ? : 0 0 0
553 }
554 1219 return $v;
555 }
556  
557  
558 2097 ▶ if (defined $type->{validate}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type->{"validate"}) 2025 72 2097
559 2025 ▶ croak 'Identifier did not validate against type' unless $id =~ $type->{validate};
Branch: 1 branch
BranchTrueFalseTotal
unless $id =~ /$type->{"validate"}/u 0 2025 2025
560 }
561  
562 2097 $self->{type} = $type;
563 2097 $self->{id} = $id;
564  
565 2097 foreach my $key (qw(validate namespace generator request generate displayname displaycolour icontext description)) {
566 18873 ▶ next unless defined $opts{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{$key} 17608 1265 18873
567 1265 ▶ $self->{$key} //= $opts{$key};
Condition33%1/3
$self->{$key} //= $opts{$key}
l!l&&r!l&&!r
012650
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 2097 foreach my $key (qw(namespace generator)) {
571 4194 ▶ if (defined(my $v = $self->{$key})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $v = $self->{$key})) 3 4191 4194
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 2097 ▶ if (defined(my $tagname = $opts{tagname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $tagname = $opts{"tagname"})) 0 2097 2097
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 2097 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 532 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
618 532 my ($self) = @_;
619 532 return $self->{type};
620 }
621  
622  
623  
624 382 ▶sub id {
Subroutine id: called CC=1 SCAR=0.0
Pod documented
625 382 my ($self) = @_;
626 382 return $self->{id};
627 }
628  
629  
630 24192 ▶sub uuid {
Subroutine uuid: called CC=9 SCAR=22.1
Pod documented
631 24192 my ($self, %opts) = @_;
632  
633 24192 ▶ 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"} 1103 23089 24192
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
2953201361103
not $opts{"no_defaults"} and defined $self->{"id_cache"}
!ll&&!rl&&r
179277421239
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 23089 ▶ if ($self->{type} == $well_known_uuid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} == $well_known_uuid) 22956 133 23089
636 22956 return $self->{id};
637 }
638  
639 133 ▶ unless ($opts{no_defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"no_defaults"}) 111 22 133
640 # Try to generate a UUID and recheck cache:
641 111 $self->_generate;
642 111 ▶ 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"} 71 40 111
Condition66%2/3
defined $self->{"id_cache"} and defined $self->{"id_cache"}{"8be115d2-dc2f-4a98-91e1-a6e3075cbc31"}
!ll&&!rl&&r
40071
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 62 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 62 0 62
646 0 croak 'Identifier has no valid UUID';
647 }
648  
649 2930 ▶sub oid {
Subroutine oid: called CC=8 SCAR=21.7
Pod documented
650 2930 my ($self, %opts) = @_;
651 2930 my $type = $well_known{oid};
652  
653 2930 ▶ 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"} 1042 1888 2930
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
10398491042
not $opts{"no_defaults"} and defined $self->{"id_cache"}
!ll&&!rl&&r
010391891
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 1888 ▶ if ($self->{type} == $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} == $type) 0 1888 1888
656 0 return $self->{id};
657 }
658  
659 1888 ▶ unless ($opts{no_defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"no_defaults"}) 1888 0 1888
660 1888 ▶ if (defined(my $uuid = $self->uuid(default => undef))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $uuid = $self->uuid("default", undef))) 1868 20 1888
661 1868 return $self->{id_cache}{WK_OID()} = sprintf('2.25.%s', Math::BigInt->new('0x'.$uuid =~ tr/-//dr));
662 }
663 }
664  
665 20 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 20 0 20
666 0 croak 'Identifier has no valid OID';
667 }
668  
669 2927 ▶sub uri {
Subroutine uri: called CC=17 SCAR=31.9
Pod documented
670 2927 my ($self, %opts) = @_;
671 2927 my $type = $well_known{uri};
672  
673 2927 ▶ 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"}) 1030 1897 2927
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
2218751030
not $opts{"no_defaults"} || defined $opts{"style"} and defined $self->{"id_cache"}
!ll&&!rl&&r
1212905
$opts{'no_defaults'} || defined $opts{'style'}
l!l&&r!l&&!r
012926
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 1030 return $self->{id_cache}{WK_URI()};
675 }
676  
677 1897 ▶ if ($self->{type} == $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} == $type) 241 1656 1897
678 241 return $self->{id};
679 }
680  
681 1656 ▶ $opts{style} //= 'urn';
Condition100%2/2
$opts{"style"} //= "urn"
l!l
11655
MC/DC100%1/1
$opts{"style"} //= "urn"
$opts{"style"}
Truth table100%2/2
A
A= $opts{"style"}
Aresult
11
00
682  
683 1656 ▶ unless ($opts{no_defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts{"no_defaults"}) 1656 0 1656
684 1656 ▶ if ($self->{type} == $well_known{wd}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->{'type'} == $well_known{'wd'}) { } 68 1588 1656
elsif ($self->{'type'} == $well_known{'doi'}) { } 0 1588 1588
elsif (defined(my $uuid = $self->uuid('default', undef)) and $opts{'style'} eq 'urn') { } 1587 1 1588
elsif ($enabled_oid and defined(my $oid = $self->oid('default', undef)) and $opts{'style'} eq 'urn') { } 0 1 1
685 68 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
011587
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 1587 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 2936 ▶sub sid {
Subroutine sid: called CC=5 SCAR=16.8
Pod documented
705 2936 my ($self, %opts) = @_;
706 2936 my $type = $well_known{sid};
707 2936 ▶ 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"} 1352 1584 2936
Condition100%3/3
defined $self->{"id_cache"} and defined $self->{"id_cache"}{"f87a38cb-fd13-4e15-866c-e49901adbec5"}
!ll&&!rl&&r
2215621352
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 1584 ▶ if ($self->{type} == $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} == $type) 0 1584 1584
709 0 return $self->{id};
710 }
711  
712 1584 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 1584 0 1584
713 0 croak 'Identifier has no valid SID';
714 }
715  
716  
717  
718 448 ▶sub ise {
Subroutine ise: called CC=8 SCAR=23.4
Pod documented
719 448 my ($self, %opts) = @_;
720 448 my $type = $self->{type};
721 448 my $have_default = exists $opts{default};
722 448 my $default = delete $opts{default};
723 448 my $value;
724  
725 448 ▶ 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'}) { } 418 30 448
Condition83%5/6
$type == $well_known{"uuid"} or $type == $well_known{"oid"} or $type == $well_known{"uri"}
l!l&&r!l&&!r
3704830
$type == $well_known{"uuid"} or $type == $well_known{"oid"}
l!l&&r!l&&!r
370078
MC/DC66%2/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 table75%3/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 418 $value = $self->{id};
727 } else {
728 30 $opts{default} = undef;
729 30 ▶ $value = $self->uuid(%opts) // $self->oid(%opts) // $self->uri(%opts);
Condition33%2/6
($self->uuid(%opts) // $self->oid(%opts)) // $self->uri(%opts)
l!l&&r!l&&!r
3000
$self->uuid(%opts) // $self->oid(%opts)
l!l&&r!l&&!r
3000
MC/DC0%0/3
($self->uuid(%opts) // $self->oid(%opts)) // $self->uri(%opts)
$self->uuid(%opts) $self->oid(%opts) $self->uri(%opts)
Truth table25%1/4
A // B // C
A= $self->uuid(%opts)B= $self->oid(%opts)C= $self->uri(%opts)
ABCresult
1XX1
01X1
0011
0000
730 }
731  
732 448 ▶ return $value if defined $value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 448 0 448
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 1208 ▶sub as {
Subroutine as: called CC=79 SCAR=74.3
Pod documented
739 1208 my ($self, $as, %opts) = @_;
740  
741 1208 ▶ $as = $opts{rawtype} if $as eq 'raw' && defined($opts{rawtype});
Branch: 1 branch
BranchTrueFalseTotal
if $as eq "raw" and defined $opts{"rawtype"} 248 960 1208
Condition66%2/3
$as eq "raw" and defined $opts{"rawtype"}
!ll&&!rl&&r
9600248
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 1208 ▶ 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__)) 13 1195 1208
Condition66%4/6
ref $as and eval { do { $as->isa(__PACKAGE__) } } and $self->isa(__PACKAGE__)
!ll&&!rl&&r
1195013
ref $as and eval { do { $as->isa(__PACKAGE__) } }
!ll&&!rl&&r
1195013
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 13 my $type_uuid = $as->uuid;
745 13 my $next_type;
746  
747 13 ▶ return $self->id if $self->type->eq($as);
Branch: 1 branch
BranchTrueFalseTotal
if $self->type->eq($as) 3 10 13
748  
749 10 foreach my $test (qw(uuid oid uri sid)) {
750 40 ▶ if ($as == $well_known{$test}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($as == $well_known{$test}) 6 34 40
751 6 $next_type = $test;
752 6 last;
753 }
754 }
755  
756 10 ▶ if (defined $next_type) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $next_type) { } 6 4 10
757 6 ▶ 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 6 6
Condition33%2/6
not $opts{"no_defaults"} and defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid}
!ll&&!rl&&r
600
not $opts{"no_defaults"} and defined $self->{"id_cache"}
!ll&&!rl&&r
600
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 6 $as = $next_type;
759 } else {
760 4 ▶ 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 1 4
Condition66%2/3
defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid}
!ll&&!rl&&r
103
MC/DC50%1/2
defined $self->{"id_cache"} and defined $self->{"id_cache"}{$type_uuid}
defined $self->{"id_cache"} defined $self->{"id_cache"}{$type_uuid}
Truth table66%2/3
A and B
A= defined $self->{"id_cache"}B= defined $self->{"id_cache"}{$type_uuid}
ABresult
0X0
100
111
761 1 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 1 0 1
762 0 croak 'Unknown/Unsupported as: '.$as;
763 }
764 }
765  
766 1201 ▶ 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) } } 1191 10 1201
Condition83%5/6
$as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } }
!ll&&!rl&&r
641191
$as =~ /^[A-Z]/u or $as =~ /::/u
l!l&&r!l&&!r
119506
MC/DC66%2/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 table60%3/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 10 ▶ if ($self->isa('Data::Identifier::Interface::Subobjects')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa("Data::Identifier::Interface::Subobjects")) 0 10 10
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 10 ▶ if (defined(my $so = $opts{so})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $so = $opts{"so"})) 0 10 10
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 10 ▶ $self = __PACKAGE__->new(from => $self) unless eval {$self->isa(__PACKAGE__)};
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $self->isa(__PACKAGE__) } } 0 10 10
783  
784 10 ▶ 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 10 10
Condition66%4/6
$as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } }
!ll&&!rl&&r
640
$as =~ /^[A-Z]/u or $as =~ /::/u
l!l&&r!l&&!r
406
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 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
785  
786 10 ▶ 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') { } 6 4 10
elsif ($as eq __PACKAGE__) { } 0 4 4
elsif ($as eq 'URI') { } 0 4 4
elsif ($as eq 'Mojo::URL') { } 0 4 4
elsif ($as eq 'Data::URIID::Result' and defined $opts{'extractor'}) { } 0 4 4
elsif ($as eq 'Data::URIID::Service' and defined $opts{'extractor'}) { } 0 4 4
elsif ($as eq 'SIRTX::Datecode' and eval { do { require SIRTX::Datecode; 'SIRTX::Datecode'->VERSION(v0.03); 1 } }) { } 0 4 4
elsif ($as eq 'Data::URIID::Colour' and eval { do { require Data::URIID; require Data::URIID::Colour; 'Data::URIID::Colour'->VERSION(v0.14); 1 } }) { } 0 4 4
elsif ($as eq 'Data::TagDB::Tag' and defined $opts{'db'}) { } 0 4 4
elsif ($as eq 'File::FStore::File' and defined $opts{'store'}) { } 0 4 4
elsif ($as eq 'Business::ISBN' and $self->type->eq('gtin')) { } 0 4 4
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') } }) { } 4 0 4
elsif ($as =~ /^Convert::Color(?:::.+)?\z/u) { } 0 0 0
elsif (defined(my $r = $perl_package_registrations{$as})) { } 0 0 0
Condition50%6/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
604
$as eq "uuid" or $as eq "oid" or $as eq "uri" or $as eq "sid"
l!l&&r!l&&!r
064
$as eq "uuid" or $as eq "oid" or $as eq "uri"
l!l&&r!l&&!r
0010
$as eq "uuid" or $as eq "oid"
l!l&&r!l&&!r
0010
MC/DC20%1/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 table33%2/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 6 my $func = $self->can($as);
788 6 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})) {
Condition33%1/3
$as eq "Data::URIID::Result" and defined $opts{"extractor"}
!ll&&!rl&&r
400
MC/DC0%0/2
$as eq "Data::URIID::Result" and defined $opts{"extractor"}
$as eq "Data::URIID::Result" defined $opts{"extractor"}
Truth table33%1/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})) {
Condition33%1/3
$as eq "Data::URIID::Service" and defined $opts{"extractor"}
!ll&&!rl&&r
400
MC/DC0%0/2
$as eq "Data::URIID::Service" and defined $opts{"extractor"}
$as eq "Data::URIID::Service" defined $opts{"extractor"}
Truth table33%1/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 {
Condition33%1/3
$as eq "SIRTX::Datecode" and eval { do { require SIRTX::Datecode; "SIRTX::Datecode"->VERSION(v0.03); 1 } }
!ll&&!rl&&r
400
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 table33%1/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 {
Condition33%1/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
400
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 table33%1/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})) {
Condition33%1/3
$as eq "Data::TagDB::Tag" and defined $opts{"db"}
!ll&&!rl&&r
400
MC/DC0%0/2
$as eq "Data::TagDB::Tag" and defined $opts{"db"}
$as eq "Data::TagDB::Tag" defined $opts{"db"}
Truth table33%1/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})) {
Condition33%1/3
$as eq "File::FStore::File" and defined $opts{"store"}
!ll&&!rl&&r
400
MC/DC0%0/2
$as eq "File::FStore::File" and defined $opts{"store"}
$as eq "File::FStore::File" defined $opts{"store"}
Truth table33%1/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')) {
Condition33%1/3
$as eq "Business::ISBN" and $self->type->eq("gtin")
!ll&&!rl&&r
400
MC/DC0%0/2
$as eq "Business::ISBN" and $self->type->eq("gtin")
$as eq "Business::ISBN" $self->type->eq("gtin")
Truth table33%1/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/ &&
Condition33%2/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
004
$as =~ /^Math::Big(?:Int|Rat|Float)\z/u and defined $self->request("default", undef, "no_defaults", 1)
!ll&&!rl&&r
004
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 table25%1/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 4 ▶ 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')}) {
Condition66%2/3
$self->generator->eq('53863a15-68d4-448d-bd69-a9b19289a191') || $self->generator->eq('e8aa9e01-8d37-4b4b-8899-42ca0a2a906f')
l!l&&r!l&&!r
310
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 table66%2/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 4 ▶ if ($as eq 'Math::BigInt') {
Branch: 3 branches
BranchTrueFalseTotal
if ($as eq 'Math::BigInt') { } 4 0 4
elsif ($as eq 'Math::BigRat') { } 0 0 0
elsif ($as eq 'Math::BigFloat') { } 0 0 0
847 # Already loaded.
848 4 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 394 ▶sub eq {
Subroutine eq: called CC=9 SCAR=22.2
Pod documented
891 394 my ($self, $other) = @_;
892  
893 394 foreach my $e ($self, $other) {
894 788 ▶ if (defined($e) && !scalar(eval {$e->isa(__PACKAGE__)})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } }) 55 733 788
Condition66%2/3
defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } }
!ll&&!rl&&r
073355
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 55 ▶ if (defined $well_known{$e}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $well_known{$e}) { } 38 17 55
896 38 $e = $well_known{$e}
897 } else {
898 17 $e = Data::Identifier->new(from => $e);
899 }
900 }
901 }
902  
903 394 ▶ if (defined($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self) { } 394 0 394
904 394 ▶ return undef unless defined $other;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 394 394
905 394 ▶ return 1 if $self == $other;
Branch: 1 branch
BranchTrueFalseTotal
if $self == $other 191 203 394
906 203 ▶ if ($self->type->eq($other->type)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->type->eq($other->type)) { } 137 66 203
907 137 return $self->id eq $other->id;
908 } else {
909 66 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 38 ▶sub null_to_undef {
Subroutine null_to_undef: called CC=5 SCAR=16.8
Pod documented
957 38 my ($self, @opts) = @_;
958  
959 38 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 38 38
960  
961 38 ▶ return undef unless defined $self;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self 0 38 38
962  
963 38 ▶ unless (eval {$self->isa(__PACKAGE__)}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $self->isa(__PACKAGE__) } }) 0 38 38
964 0 $self = __PACKAGE__->new(from => $self);
965 }
966  
967 38 ▶ return undef if $self->eq('null');
Branch: 1 branch
BranchTrueFalseTotal
if $self->eq("null") 8 30 38
968  
969 30 return $self;
970 }
971  
972  
973 28 ▶sub is_null {
Subroutine is_null: called CC=2 SCAR=7.1
Pod documented
974 28 my ($self, @opts) = @_;
975  
976 28 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 28 28
977  
978 28 return !defined Data::Identifier::null_to_undef($self);
979 }
980  
981  
982 #@returns __PACKAGE__
983 71 ▶sub namespace {
Subroutine namespace: called CC=4 SCAR=16.6
Pod documented
984 71 my ($self, %opts) = @_;
985 71 my $has_default = exists $opts{default};
986 71 my $default = delete $opts{default};
987  
988 71 delete $opts{no_defaults};
989  
990 71 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 71 71
991  
992 71 ▶ return $self->{namespace} if defined $self->{namespace};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"namespace"} 71 0 71
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 9 ▶sub generator {
Subroutine generator: called CC=4 SCAR=14.2
Pod documented
1002 9 my ($self, %opts) = @_;
1003 9 my $has_default = exists $opts{default};
1004 9 my $default = delete $opts{default};
1005  
1006 9 delete $opts{no_defaults};
1007  
1008 9 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 9 9
1009  
1010 9 ▶ return $self->{generator} if defined $self->{generator};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"generator"} 6 3 9
1011  
1012 3 ▶ return $default if $has_default;
Branch: 1 branch
BranchTrueFalseTotal
if $has_default 3 0 3
1013  
1014 0 croak 'No generator';
1015 }
1016  
1017  
1018 9 ▶sub request {
Subroutine request: called CC=4 SCAR=16.6
Pod documented
1019 9 my ($self, %opts) = @_;
1020 9 my $has_default = exists $opts{default};
1021 9 my $default = delete $opts{default};
1022  
1023 9 delete $opts{no_defaults};
1024  
1025 9 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 9 9
1026  
1027 9 ▶ return $self->{request} if defined $self->{request};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"request"} 9 0 9
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 2919 ▶sub register {
Subroutine register: called CC=6 SCAR=18.0
Pod documented
1037 2919 my ($self) = @_;
1038 2919 $registered{$self->{type}->uuid}{$self->{id}} = $self;
1039  
1040 2919 foreach my $type_name (qw(uuid oid uri sid)) {
1041 11676 ▶ my $f = $self->can($type_name) || next;
Condition50%1/2
$self->can($type_name) || (next)
l!l
116760
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 11676 ▶ my $v = $self->$f(default => undef) // next;
Condition100%2/2
$self->$f("default", undef) // (next)
l!l
100541622
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 10054 $registered{$well_known{$type_name}->uuid}{$v} = $self;
1044 }
1045  
1046 2919 foreach my $extra (keys %{$self->{id_cache}}) {
1047 7699 ▶ my $v = $self->{id_cache}{$extra} // next;
Condition50%1/2
$self->{"id_cache"}{$extra} // (next)
l!l
76990
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 7699 $registered{$extra}{$v} = $self;
1049 }
1050  
1051 2919 return $self;
1052 }
1053  
1054  
1055  
1056 958 ▶sub displayname {
Subroutine displayname: called CC=8 SCAR=22.0
Pod documented
1057 958 my ($self, %opts) = @_;
1058  
1059 958 ▶ if (defined(my $displayname = $self->{displayname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $displayname = $self->{"displayname"})) 900 58 958
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 58 ▶ 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))) 22 36 58
1067 22 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 4 ▶sub icontext {
Subroutine icontext: called CC=6 SCAR=20.3
Pod documented
1090 4 my ($self, %opts) = @_;
1091  
1092 4 ▶ if (defined(my $value = $self->{icontext})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $value = $self->{"icontext"})) 3 1 4
1093 3 ▶ $value = $self->$value() if ref $value;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 0 3 3
1094  
1095 # recheck and return as any of the above conversions could result in $displayname becoming invalid.
1096 3 ▶ return $value if defined($value) && length($value);
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and length $value 3 0 3
Condition33%1/3
defined $value and length $value
!ll&&!rl&&r
003
MC/DC0%0/2
defined $value and length $value
defined $value length $value
Truth table33%1/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
1097 }
1098  
1099 1 ▶ return $opts{default} if exists $opts{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"default"} 1 0 1
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 58 ▶sub tagname {
Subroutine tagname: called CC=6 SCAR=19.2
Pod documented
1118 58 my ($self, %opts) = @_;
1119 58 my $had_default = exists $opts{default};
1120 58 my $default = delete $opts{default};
1121 58 my $list = delete $opts{list};
1122  
1123 58 delete $opts{no_defaults}; # for compatibility.
1124  
1125 58 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 58 58
1126  
1127 58 ▶ if (defined(my $tagname = $self->{tagname})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $tagname = $self->{"tagname"})) 22 36 58
1128 0 ▶ return @{$tagname} if $list;
Branch: 1 branch
BranchTrueFalseTotal
if $list 0 22 22
1129  
1130 22 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 28 ▶sub import {
Subroutine import: called CC=11 SCAR=46.2
1143 28 my ($pkg, $opts) = @_;
1144 28 ▶ return unless defined $opts;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts 28 0 28
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 111 ▶sub _generate {
Subroutine _generate: called CC=8 SCAR=21.3
1170 111 my ($self) = @_;
1171 111 ▶ unless (exists $self->{_generate}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_generate"}) 91 20 111
1172 91 my __PACKAGE__ $type = $self->type;
1173  
1174 91 ▶ if (defined(my $generate = $type->{generate})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $generate = $type->{"generate"})) 71 20 91
1175 71 ▶ unless (ref $generate) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $generate) 71 0 71
1176 71 $self->{generate} = $generate = {style => $generate};
1177 }
1178  
1179 71 ▶ $self->{id_cache} //= {};
Condition50%1/2
$self->{"id_cache"} //= {}
l!l
071
MC/DC0%0/1
$self->{"id_cache"} //= {}
$self->{"id_cache"}
Truth table50%1/2
A
A= $self->{"id_cache"}
Aresult
11
00
1180  
1181 71 ▶ if (defined(my __PACKAGE__ $ns = eval {$type->namespace->uuid})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my Data::Identifier $ns = eval { do { $type->namespace->uuid } })) 71 0 71
1182 71 my $style = $generate->{style};
1183 71 my $input;
1184  
1185 71 ▶ if ($style eq 'id-based') {
Branch: 1 branch
BranchTrueFalseTotal
if ($style eq 'id-based') { } 71 0 71
1186 71 $input = lc($self->id);
1187 } else {
1188 0 croak 'Unsupported generator style';
1189 }
1190  
1191 71 ▶ if (defined $input) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $input) 71 0 71
1192 71 require Data::Identifier::Generate;
1193 71 $self->{id_cache}{WK_UUID()} = Data::Identifier::Generate->_uuid_v5($ns, $input);
1194 }
1195 }
1196 }
1197 }
1198 111 $self->{_generate} = undef;
1199 }
1200  
1201 18 ▶sub _known_provider {
Subroutine _known_provider: called CC=5 SCAR=16.3
1202 18 my ($pkg, $class, %opts) = @_;
1203 18 ▶ croak 'Unsupported options passed' if scalar(keys %opts);
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 18 18
1204  
1205 18 ▶ if ($class eq 'wellknown') {
Branch: 2 branches
BranchTrueFalseTotal
if ($class eq 'wellknown') { } 15 3 18
elsif ($class eq 'registered' or $class eq ':all') { } 3 0 3
1206 15 state $wellknown = do {
1207 13 my %hash = map{$_ => $_} values(%well_known), map {values %{$_}} values(%registered);
1208 13 [values %hash];
1209 };
1210  
1211 15 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 474 ▶sub _add_tagnames {
Subroutine _add_tagnames: called CC=2 SCAR=6.9
1222 474 my ($self, @tagnames) = @_;
1223 474 ▶ my %tagnames = map {$_ => undef} grep {defined} @{$self->{tagname} //= []}, @tagnames;
Condition100%2/2
$self->{"tagname"} //= []
l!l
45429
MC/DC100%1/1
$self->{"tagname"} //= []
$self->{"tagname"}
Truth table100%2/2
A
A= $self->{"tagname"}
Aresult
11
00
1224 474 @{$self->{tagname}} = keys %tagnames;
1225 474 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 13 1;
1234  
1235 __END__
↑ Summary Identifier/Cloudlet.pm »