Branch Coverage

lib/Data/Identifier.pm
Criterion Covered Total %
branch 112 292 38.3


line true false branch
315 0 1113 unless defined $type
316 0 1113 unless defined $id
318 55 1058 if (not ref $type and $type eq "from")
319 0 55 if (ref $id) { }
321 0 0 if ($id->isa('Data::Identifier')) { }
0 0 elsif ($id->isa('URI')) { }
0 0 elsif ($id->isa('Mojo::URL')) { }
0 0 elsif ($id->isa('Data::URIID::Result')) { }
0 0 elsif ($id->isa('Data::URIID::Base') or $id->isa('Data::URIID::Colour') or $id->isa('Data::URIID::Service')) { }
0 0 elsif ($id->isa('Data::TagDB::Tag')) { }
0 0 elsif ($id->isa('File::FStore::File') or $id->isa('File::FStore::Adder') or $id->isa('File::FStore::Base')) { }
0 0 elsif ($id->isa('SIRTX::Datecode')) { }
0 0 elsif ($id->isa('Business::ISBN')) { }
0 0 elsif ($id->isa('Data::Identifier::Interface::Simple')) { }
322 0 0 if (scalar keys %opts) { }
351 0 0 unless (scalar keys %opts)
374 881 232 if (not ref $type and $type eq "ise")
375 0 881 unless defined $id
377 881 0 if ($id =~ /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$/u) { }
0 0 elsif ($id =~ /^[0-2](?:\.(?:0|[1-9][0-9]*))+$/u) { }
0 0 elsif ($id =~ /^[a-zA-Z][a-zA-Z0-9\+\.\-]+:/u) { }
381 7 874 if (not defined $type and $id eq "8be115d2-dc2f-4a98-91e1-a6e3075cbc31")
394 133 980 unless (ref $type)
395 6 127 if ($type =~ /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$/u) { }
8 119 elsif ($type eq 'wellknown') { }
400 0 8 unless defined $self
405 0 125 unless defined $type
408 0 1105 unless $type->isa(__PACKAGE__)
411 3 1102 if ($type == ($well_known{'uri'} // 0))
414 1 2 if ($uri =~ /^urn:uuid:([0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})$/u) { }
0 2 elsif ($uri =~ /^urn:oid:([0-2](?:\.(?:0|[1-9][0-9]*))+)$/u) { }
0 2 elsif ($uri =~ m[^https?://www\.wikidata\.org/entity/([QPL][1-9][0-9]*)$]u) { }
0 2 elsif ($uri =~ m[^https?://doi\.org/(10\..+)$]u) { }
2 0 elsif ($uri =~ m[^https?://uriid\.org/([^/]+)/[^/]+]u) { }
428 2 0 if (defined $uuid_org_to_uuid{$ptype} or $ptype =~ /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/u)
431 2 0 if (scalar @path_segments == 3 and $path_segments[0] eq "")
439 1025 80 if ($type == ($well_known_uuid // 0)) { }
1 79 elsif ($type == ($well_known{'oid'} // 0)) { }
442 1 0 if ($id =~ /^2\.25\.([1-9][0-9]*)$/u)
452 552 553 if (defined(my $v = $registered{$type->uuid}{$id}))
457 544 9 if (defined $type->{'validate'})
458 0 544 unless $id =~ /$type->{'validate'}/u
465 3154 164 unless defined $opts{$key}
470 31 1075 if (defined(my $v = $self->{$key}))
471 31 0 unless (ref $v)
486 0 0 if (ref $type)
487 0 0 if ($type == $well_known_uuid) { }
494 0 0 if ($type ne "ise" and $type ne "uuid")
529 0 7167 if not $opts{'no_defaults'} and defined $self->{'id_cache'} and defined $self->{'id_cache'}{'8be115d2-dc2f-4a98-91e1-a6e3075cbc31'}
531 7181 27 if ($self->{'type'} == $well_known_uuid)
535 3 24 unless ($opts{'no_defaults'})
538 3 0 if defined $self->{'id_cache'} and defined $self->{'id_cache'}{'8be115d2-dc2f-4a98-91e1-a6e3075cbc31'}
541 24 0 if exists $opts{'default'}
549 488 428 if not $opts{'no_defaults'} and defined $self->{'id_cache'} and defined $self->{'id_cache'}{'d08dc905-bbf6-4183-b219-67723c3c8374'}
551 0 428 if ($self->{'type'} == $type)
555 428 0 unless ($opts{'no_defaults'})
556 428 0 if (defined(my $uuid = $self->uuid("default", undef)))
561 0 0 if exists $opts{'default'}
569 488 428 if (not $opts{'no_defaults'} || defined $opts{'style'} and defined $self->{'id_cache'} and defined $self->{'id_cache'}{'a8d1637d-af19-49e9-9ef8-6bc1fbcf6439'})
573 0 429 if ($self->{'type'} == $type)
579 429 0 unless ($opts{'no_defaults'})
580 0 429 if ($self->{'type'} == $well_known{'wd'}) { }
0 429 elsif ($self->{'type'} == $well_known{'doi'}) { }
428 1 elsif (defined(my $uuid = $self->uuid('default', undef)) and $opts{'style'} eq 'urn') { }
0 1 elsif ($enabled_oid and defined(my $oid = $self->oid('default', undef)) and $opts{'style'} eq 'urn') { }
596 0 0 if exists $opts{'default'}
603 625 294 if defined $self->{'id_cache'} and defined $self->{'id_cache'}{'f87a38cb-fd13-4e15-866c-e49901adbec5'}
604 0 294 if ($self->{'type'} == $type)
608 294 0 if exists $opts{'default'}
621 22 0 if ($type == $well_known{'uuid'} or $type == $well_known{'oid'} or $type == $well_known{'uri'}) { }
628 22 0 if defined $value
629 0 0 if $have_default
637 122 6 if $as eq "raw" and defined $opts{'rawtype'}
639 6 122 if (ref $as and eval { do { $as->isa(__PACKAGE__) } })
643 0 6 if $self->type->eq($as)
646 3 21 if ($as == $well_known{$test})
652 3 3 if (defined $next_type) { }
653 0 0 if not $opts{'no_defaults'} and defined $self->{'id_cache'} and defined $self->{'id_cache'}{$type_uuid}
656 3 0 if defined $self->{'id_cache'} and defined $self->{'id_cache'}{$type_uuid}
657 0 0 if exists $opts{'default'}
662 122 3 if $as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } }
664 0 3 if ($self->isa("Data::Identifier::Interface::Subobjects"))
669 0 3 if (defined(my $so = $opts{'so'}))
674 0 3 unless eval { do { $self->isa(__PACKAGE__) } }
676 3 0 if ($as eq 'uuid' or $as eq 'oid' or $as eq 'uri' or $as eq 'sid' or $as eq 'ise') { }
0 0 elsif ($as eq __PACKAGE__) { }
0 0 elsif ($as eq 'URI') { }
0 0 elsif ($as eq 'Mojo::URL') { }
0 0 elsif ($as eq 'Data::URIID::Result' and defined $opts{'extractor'}) { }
0 0 elsif ($as eq 'Data::URIID::Service' and defined $opts{'extractor'}) { }
0 0 elsif ($as eq 'SIRTX::Datecode' and eval { do { require SIRTX::Datecode; 'SIRTX::Datecode'->VERSION(v0.03); 1 } }) { }
0 0 elsif ($as eq 'Data::URIID::Colour' and eval { do { require Data::URIID; require Data::URIID::Colour; 'Data::URIID::Colour'->VERSION(v0.14); 1 } }) { }
0 0 elsif ($as eq 'Data::TagDB::Tag' and defined $opts{'db'}) { }
0 0 elsif ($as eq 'File::FStore::File' and defined $opts{'store'}) { }
0 0 elsif ($as eq 'Business::ISBN' and $self->type->eq('gtin')) { }
686 0 0 if defined $val
687 0 0 if ($had_default)
688 0 0 if ref $default
699 0 0 if defined $val
700 0 0 if ($had_default)
701 0 0 if ref $default
723 0 0 if ($opts{'autocreate'}) { }
733 0 0 if defined $val and $val->is_valid
736 0 0 if exists $opts{'default'}
745 4 78 if (defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } })
746 0 4 if (defined $well_known{$e}) { }
754 41 0 if (defined $self) { }
755 0 41 unless defined $other
756 30 11 if $self == $other
757 0 11 unless $self->type->eq($other->type)
769 0 0 if (defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } })
770 0 0 if (defined $well_known{$e}) { }
778 0 0 if (defined $self) { }
779 0 0 unless defined $other
780 0 0 if $self == $other
781 0 0 if ((my $r = $self->type->cmp($other->type)) != 0)
789 0 0 if (my($sa, $sb) = $self_id =~ /^([^0-9]*)([0-9]+)$/u and my($oa, $ob) = $other_id =~ /^([^0-9]*)([0-9]+)$/u)
791 0 0 if $r
811 0 3 if scalar keys %opts
813 3 0 if defined $self->{'namespace'}
815 0 0 if $has_default
829 0 0 if scalar keys %opts
831 0 0 if defined $self->{'generator'}
833 0 0 if $has_default
846 0 0 if scalar keys %opts
848 0 0 if defined $self->{'request'}
850 0 0 if $has_default
880 13 0 if (defined(my $displayname = $self->{'displayname'}))
881 0 13 if ref $displayname
884 13 0 if defined $displayname and length $displayname
887 0 0 unless $opts{'no_defaults'}
888 0 0 if exists $opts{'default'}
901 15 0 unless defined $opts
902 0 0 unless ref $opts eq "HASH"
904 0 0 if (defined(my $disable = $opts->{'disable'}))
905 0 0 unless ref $disable
907 0 0 if ($to_disable eq 'oid') { }
919 3 0 unless (exists $self->{'_generate'})
922 3 0 if (defined(my $generate = $type->{'generate'}))
923 3 0 unless (ref $generate)
929 3 0 if (defined(my Data::Identifier $ns = eval { do { $type->namespace->uuid } }))
933 3 0 if ($style eq 'id-based') { }
939 3 0 if (defined $input)
951 0 9 if scalar keys %opts
953 8 1 if ($class eq 'wellknown') { }
1 0 elsif ($class eq 'registered' or $class eq ':all') { }