Branch Coverage

lib/Data/Identifier.pm
Criterion Covered Total %
branch 141 344 40.9


line true false branch
329 0 1347 unless defined $type
330 0 1347 unless defined $id
332 128 1219 if (not ref $type and $type eq "from")
333 14 114 if (ref $id) { }
335 14 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')) { }
0 0 elsif ($id->isa('JSON::PP::Boolean') or $id->isa('JSON::XS::Boolean')) { }
336 0 14 if (scalar keys %opts) { }
357 0 0 if $id->isa("Data::URIID::Colour")
369 0 0 unless (scalar keys %opts)
395 968 365 if (not ref $type and $type eq "ise")
396 0 968 unless defined $id
398 956 12 if ($id =~ /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\z/u) { }
0 12 elsif ($id =~ /^[0-2](?:\.(?:0|[1-9][0-9]*))+\z/u) { }
12 0 elsif ($id =~ /^[a-zA-Z][a-zA-Z0-9\+\.\-]+:/u) { }
402 7 949 if (not defined $type and $id eq "8be115d2-dc2f-4a98-91e1-a6e3075cbc31")
415 278 1055 unless (ref $type)
416 6 272 if ($type =~ /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\z/u) { }
8 264 elsif ($type eq 'wellknown') { }
421 0 8 unless defined $self
426 0 270 unless defined $type
429 0 1325 unless $type->isa(__PACKAGE__)
432 15 1310 if ($type == ($well_known{'uri'} // 0))
435 1 14 if ($uri =~ /^urn:uuid:([0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12})\z/u) { }
0 14 elsif ($uri =~ /^urn:oid:([0-2](?:\.(?:0|[1-9][0-9]*))+)\z/u) { }
0 14 elsif ($uri =~ /^urn:isbn:([0-9Xx-]+)\z/u and scalar eval { do { require Business::ISBN; 1 } }) { }
0 14 elsif ($uri =~ m[^https?://www\.wikidata\.org/entity/([QPL][1-9][0-9]*)\z]u) { }
0 14 elsif ($uri =~ m[^https?://doi\.org/(10\..+)\z]u) { }
2 12 elsif ($uri =~ m[^https?://uriid\.org/([^/]+)/[^/]+]u) { }
454 2 0 if (defined $uuid_org_to_uuid{$ptype} or $ptype =~ /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}\z/u)
457 2 0 if (scalar @path_segments == 3 and $path_segments[0] eq "")
465 1226 99 if ($type == ($well_known_uuid // 0)) { }
1 98 elsif ($type == ($well_known{'oid'} // 0)) { }
468 1 0 if ($id =~ /^2\.25\.([1-9][0-9]*)\z/u)
478 650 675 if (defined(my $v = $registered{$type->uuid}{$id}))
483 666 9 if (defined $type->{'validate'})
484 0 666 unless $id =~ /$type->{'validate'}/u
491 5826 249 unless defined $opts{$key}
496 3 1347 if (defined(my $v = $self->{$key}))
497 3 0 unless (ref $v)
503 0 675 if (defined(my $tagname = $opts{'tagname'}))
505 0 0 unless ref $tagname
508 0 0 if (scalar @{$tagname;})
522 0 0 if (ref $type)
523 0 0 if ($type == $well_known_uuid) { }
530 0 0 if ($type ne "ise" and $type ne "uuid")
565 6 8626 if not $opts{'no_defaults'} and defined $self->{'id_cache'} and defined $self->{'id_cache'}{'8be115d2-dc2f-4a98-91e1-a6e3075cbc31'}
567 8639 55 if ($self->{'type'} == $well_known_uuid)
571 33 22 unless ($opts{'no_defaults'})
574 9 24 if defined $self->{'id_cache'} and defined $self->{'id_cache'}{'8be115d2-dc2f-4a98-91e1-a6e3075cbc31'}
577 46 0 if exists $opts{'default'}
585 535 556 if not $opts{'no_defaults'} and defined $self->{'id_cache'} and defined $self->{'id_cache'}{'d08dc905-bbf6-4183-b219-67723c3c8374'}
587 0 556 if ($self->{'type'} == $type)
591 556 0 unless ($opts{'no_defaults'})
592 544 12 if (defined(my $uuid = $self->uuid("default", undef)))
597 12 0 if exists $opts{'default'}
605 527 564 if (not $opts{'no_defaults'} || defined $opts{'style'} and defined $self->{'id_cache'} and defined $self->{'id_cache'}{'a8d1637d-af19-49e9-9ef8-6bc1fbcf6439'})
609 12 553 if ($self->{'type'} == $type)
615 553 0 unless ($opts{'no_defaults'})
616 6 547 if ($self->{'type'} == $well_known{'wd'}) { }
0 547 elsif ($self->{'type'} == $well_known{'doi'}) { }
546 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') { }
632 0 0 if exists $opts{'default'}
639 639 455 if defined $self->{'id_cache'} and defined $self->{'id_cache'}{'f87a38cb-fd13-4e15-866c-e49901adbec5'}
640 0 455 if ($self->{'type'} == $type)
644 455 0 if exists $opts{'default'}
657 143 0 if ($type == $well_known{'uuid'} or $type == $well_known{'oid'} or $type == $well_known{'uri'}) { }
664 143 0 if defined $value
665 0 0 if $have_default
673 124 6 if $as eq "raw" and defined $opts{'rawtype'}
675 6 124 if (ref $as and eval { do { $as->isa(__PACKAGE__) } })
679 0 6 if $self->type->eq($as)
682 3 21 if ($as == $well_known{$test})
688 3 3 if (defined $next_type) { }
689 0 0 if not $opts{'no_defaults'} and defined $self->{'id_cache'} and defined $self->{'id_cache'}{$type_uuid}
692 3 0 if defined $self->{'id_cache'} and defined $self->{'id_cache'}{$type_uuid}
693 0 0 if exists $opts{'default'}
698 124 3 if $as =~ /^[A-Z]/u || $as =~ /::/u and eval { do { $self->isa($as) } }
700 0 3 if ($self->isa("Data::Identifier::Interface::Subobjects"))
705 0 3 if (defined(my $so = $opts{'so'}))
710 0 3 unless eval { do { $self->isa(__PACKAGE__) } }
712 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')) { }
722 0 0 if defined $val
723 0 0 if ($had_default)
724 0 0 if ref $default
735 0 0 if defined $val
736 0 0 if ($had_default)
737 0 0 if ref $default
759 0 0 if ($opts{'autocreate'}) { }
769 0 0 if defined $val and $val->is_valid
772 0 0 if exists $opts{'default'}
781 4 78 if (defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } })
782 0 4 if (defined $well_known{$e}) { }
790 41 0 if (defined $self) { }
791 0 41 unless defined $other
792 30 11 if $self == $other
793 0 11 unless $self->type->eq($other->type)
805 0 0 if (defined $e and not scalar eval { do { $e->isa(__PACKAGE__) } })
806 0 0 if (defined $well_known{$e}) { }
814 0 0 if (defined $self) { }
815 0 0 unless defined $other
816 0 0 if $self == $other
817 0 0 if ((my $r = $self->type->cmp($other->type)) != 0)
825 0 0 if (my($sa, $sb) = $self_id =~ /^([^0-9]*)([0-9]+)\z/u and my($oa, $ob) = $other_id =~ /^([^0-9]*)([0-9]+)\z/u)
827 0 0 if $r
842 0 0 if scalar @opts
844 0 0 unless defined $self
846 0 0 unless (eval { do { $self->isa(__PACKAGE__) } })
850 0 0 if $self->eq("null")
859 0 0 if scalar @opts
873 0 9 if scalar keys %opts
875 9 0 if defined $self->{'namespace'}
877 0 0 if $has_default
891 0 0 if scalar keys %opts
893 0 0 if defined $self->{'generator'}
895 0 0 if $has_default
908 0 0 if scalar keys %opts
910 0 0 if defined $self->{'request'}
912 0 0 if $has_default
942 1 15 if (defined(my $displayname = $self->{'displayname'}))
943 0 1 if ref $displayname
946 1 0 if defined $displayname and length $displayname
949 13 2 if (defined(my $tagname = $self->tagname("default", undef, "no_defaults", 1)))
953 0 2 unless $opts{'no_defaults'}
954 2 0 if exists $opts{'default'}
962 0 0 if (defined(my $value = $self->{'displaycolour'}))
963 0 0 if ref $value eq "CODE"
966 0 0 if defined $value and length $value
974 0 0 if (defined(my $value = $self->{'icontext'}))
975 0 0 if ref $value
978 0 0 if defined $value and length $value
986 0 0 if (defined(my $value = $self->{'description'}))
987 0 0 if ref $value
990 0 0 if defined $value and length $value
1005 0 21 if scalar keys %opts
1007 13 8 if (defined(my $tagname = $self->{'tagname'}))
1008 0 13 if $list
1013 8 0 if ($had_default)
1014 6 2 if $list
1024 16 0 unless defined $opts
1025 0 0 unless ref $opts eq "HASH"
1027 0 0 if (defined(my $disable = $opts->{'disable'}))
1028 0 0 unless ref $disable
1030 0 0 if ($to_disable eq 'oid') { }
1042 21 12 unless (exists $self->{'_generate'})
1045 9 12 if (defined(my $generate = $type->{'generate'}))
1046 9 0 unless (ref $generate)
1052 9 0 if (defined(my Data::Identifier $ns = eval { do { $type->namespace->uuid } }))
1056 9 0 if ($style eq 'id-based') { }
1062 9 0 if (defined $input)
1074 0 9 if scalar keys %opts
1076 8 1 if ($class eq 'wellknown') { }
1 0 elsif ($class eq 'registered' or $class eq ':all') { }