| 1 | # Copyright (c) 2023-2026 Philipp Schafft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # licensed under Artistic License 2.0 (see LICENSE file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: format independent identifier object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | package Data::Identifier::Generate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use v5.20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Encode qw(encode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Digest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Data::Identifier; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | NS_GTE => '90355e77-6942-4d82-a0b6-3a6de65bf948', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | WK_UNSIGNED_INTEGER_GENERATOR => '53863a15-68d4-448d-bd69-a9b19289a191', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | WK_SIGNED_INTEGER_GENERATOR => 'e8aa9e01-8d37-4b4b-8899-42ca0a2a906f', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | WK_UNICODE_CHARACTER_GENERATOR => 'd74f8c35-bcb8-465c-9a77-01010e8ed25c', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | WK_RGB_COLOUR_GENERATOR => '55febcc4-6655-4397-ae3d-2353b5856b34', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | WK_DATE_GENERATOR => '97b7f241-e1c5-4f02-ae3c-8e31e501e1dc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | #WK_LANGUAGE_GENERATOR => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | WK_MULTIPLICITY_GENERATOR => '19659233-0a22-412c-bdf1-8ee9f8fc4086', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | WK_MINIMUM_MULTIPLICITY_GENERATOR => '5ec197c3-1406-467c-96c7-4b1a6ec2c5c9', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | WK_STD_DIGEST_ALGO_GENERATOR => '65284e17-5550-42ef-9449-cdf13cb97a9e', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | our $VERSION = v0.38; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | my %_multiplicity_prefix = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | total => '4.1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | minimum => '4.3', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | my %_multiplicity_names = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 => 'noone', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 => 'solo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 => 'duo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 => 'trio', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | my %_multiplicity_generators = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | total => WK_MULTIPLICITY_GENERATOR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | minimum => WK_MINIMUM_MULTIPLICITY_GENERATOR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | my %_gte_simple_profiles = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'ab332382-a6f8-4a24-914d-5f823dd866c1' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | namespace => 'a13377a3-88d4-484e-90a8-245afb22a793', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | order => 'MFHCSmfhcs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | case_folding => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | strip_slash => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | strip_spaces => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 'e537db94-85b9-4125-972a-cc2ea1fdf51d' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | namespace => '52f20647-1dc7-4234-81ad-0639ab6cef60', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | order => 'FAfa', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | case_folding => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | strip_slash => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | strip_spaces => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | '60764502-18cb-41c9-8531-e4c8b43140b9' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | namespace => '1e2edf8d-d459-47cb-9d6e-0690f404fadf', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | order => 'MFHCSmfhcs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | case_folding => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | strip_slash => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | strip_spaces => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | '5aad9d75-7020-41a4-8ec6-2bf09566f985' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | namespace => 'fc9741b4-2ac7-412b-9d36-2b675fc0482b', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | order => 'NDTBndtb', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | case_folding => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | strip_slash => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | strip_spaces => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 4 | my %_generators = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | WK_UNSIGNED_INTEGER_GENERATOR() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | style => 'integer-based', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | namespace => Data::Identifier->NS_INT(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | WK_SIGNED_INTEGER_GENERATOR() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | style => 'integer-based', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | namespace => Data::Identifier->NS_INT(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | WK_UNICODE_CHARACTER_GENERATOR() => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | WK_RGB_COLOUR_GENERATOR() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | style => 'colour', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | namespace => '88d3944f-a13b-4e35-89eb-e3c1fbe53e76', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | WK_DATE_GENERATOR() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | namespace => Data::Identifier->NS_DATE(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | ▶ | icontext => "\N{TEAR-OFF CALENDAR}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | #WK_LANGUAGE_GENERATOR() => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | WK_MULTIPLICITY_GENERATOR() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | namespace => NS_GTE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | WK_MINIMUM_MULTIPLICITY_GENERATOR() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | namespace => NS_GTE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | WK_STD_DIGEST_ALGO_GENERATOR() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | style => 'id-based', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | namespace => '34f1f1d2-51be-4754-9585-83e33c5cb7e8', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | my %_hash_type_to_utag = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | '8238da08-ca93-4d67-bf40-54818aa94405' => { # rfc9530-digest-identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 'md5' => 'md-5-128', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 'sha' => 'sha-1-160', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 'sha-256' => 'sha-2-256', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 'sha-512' => 'sha-2-512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | '0d4ef6fa-0f9a-4bc8-9fc1-e4f00725397e' => { # openpgp-digest-identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 => 'md-5-128', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 => 'sha-1-160', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 => 'ripemd-1-160', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # 4 - 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 8 => 'sha-2-256', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 9 => 'sha-2-384', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 10 => 'sha-2-512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 11 => 'sha-2-224', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 12 => 'sha-3-256', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # 13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 14 => 'sha-3-512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | '039e0bb7-5dd3-40ee-a98c-596ff6cce405' => { # sirtx-numerical-identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 185 => 'sha-1-160', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 186 => 'sha-3-512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | my %_hash_utag_to_type = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 4 | my $x = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 12 | $x => {map {$_hash_type_to_utag{$x}{$_} => $_} keys %{$_hash_type_to_utag{$x}}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } keys %_hash_type_to_utag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 4 | my %_hash_type_aliases = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | rfc9530 => '8238da08-ca93-4d67-bf40-54818aa94405', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | openpgp => '0d4ef6fa-0f9a-4bc8-9fc1-e4f00725397e', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | sni => '039e0bb7-5dd3-40ee-a98c-596ff6cce405', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 70 | ▶ | sub integer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
integer: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 70 | my ($pkg, $request, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 70 | $opts{request} = $request.''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 70 | ▶ | $opts{displayname}//= $request.''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"displayname"} //= $request . ''
MC/DC0%0/1
$opts{"displayname"} //= $request . ''
$opts{"displayname"}
Truth table50%1/2
A
A= $opts{"displayname"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 70 | ▶ | $opts{generator} = $request >= 0 ? WK_UNSIGNED_INTEGER_GENERATOR : WK_SIGNED_INTEGER_GENERATOR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # We currently don't set one for $request == 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 70 | ▶ | if ($request > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 66 | ▶ | $opts{icontext} //= "\N{DOUBLE-STRUCK CAPITAL N}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"icontext"} //= "\x{2115}"
MC/DC0%0/1
$opts{"icontext"} //= "\x{2115}"
$opts{"icontext"}
Truth table50%1/2
A
A= $opts{"icontext"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } elsif ($request < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | $opts{icontext} //= "\N{DOUBLE-STRUCK CAPITAL Z}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"icontext"} //= "\x{2124}"
MC/DC0%0/1
$opts{"icontext"} //= "\x{2124}"
$opts{"icontext"}
Truth table50%1/2
A
A= $opts{"icontext"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 70 | return $pkg->generic(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | ▶ | sub unicode_character { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unicode_character: called CC=25 SCAR=47.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | my ($pkg, $type, $request, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | my Data::Identifier $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | my $unicode_cp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | my $unicode_cp_str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | my $tagname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | ▶ | croak 'No type given' unless defined $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | ▶ | croak 'No/Bad request given' unless defined($request) && length($request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $request and length $request
MC/DC0%0/2
defined $request and length $request
defined $request
length $request
Truth table33%1/3
A and B
A= defined $requestB= length $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | ▶ | if ($type eq 'unicode') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($request =~ /^[Uu]\+([0-9a-fA-F]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $unicode_cp = hex($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } elsif ($request =~ /^[0-9]+\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $unicode_cp = int($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | croak 'Bad request given: '.$request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } elsif ($type eq 'ascii') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ($request =~ /^[0-9]+\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $unicode_cp = int($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | croak 'Bad request given: '.$request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | croak 'US-ASCII character out of range: '.$unicode_cp if $unicode_cp < 0 || $unicode_cp > 0x7F; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$unicode_cp < 0 or $unicode_cp > 127
MC/DC0%0/2
$unicode_cp < 0 or $unicode_cp > 127
$unicode_cp < 0
$unicode_cp > 127
Truth table0%0/3
A or B
A= $unicode_cp < 0B= $unicode_cp > 127
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } elsif ($type eq 'raw') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 3 | ▶ | croak 'Raw value is not exactly one character long' unless length($request) == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 3 | $unicode_cp = ord($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | croak 'Bad type given: '.$type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | ▶ | croak 'Unicode character out of range: '.$unicode_cp if $unicode_cp < 0 || $unicode_cp > 0x10FFFF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$unicode_cp < 0 or $unicode_cp > 1114111
MC/DC0%0/2
$unicode_cp < 0 or $unicode_cp > 1114111
$unicode_cp < 0
$unicode_cp > 1114111
Truth table33%1/3
A or B
A= $unicode_cp < 0B= $unicode_cp > 1114111
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | $unicode_cp_str = sprintf('U+%04X', $unicode_cp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 3 | ▶ | if ($unicode_cp == 0xFFFC || $unicode_cp == 0xFFFD || $unicode_cp == 0xFEFF || $unicode_cp == 0xFFFE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$unicode_cp == 65532 or $unicode_cp == 65533 or $unicode_cp == 65279 or $unicode_cp == 65534
$unicode_cp == 65532 or $unicode_cp == 65533 or $unicode_cp == 65279
$unicode_cp == 65532 or $unicode_cp == 65533
MC/DC0%0/4
$unicode_cp == 65532 or $unicode_cp == 65533 or $unicode_cp == 65279 or $unicode_cp == 65534
$unicode_cp == 65532
$unicode_cp == 65533
$unicode_cp == 65279
$unicode_cp == 65534
Truth table20%1/5
A or B or C or D
A= $unicode_cp == 65532B= $unicode_cp == 65533C= $unicode_cp == 65279D= $unicode_cp == 65534
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | croak 'Rejected use of special character: '.$unicode_cp_str unless $opts{allow_special}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | ▶ | if ($unicode_cp > 31 && $unicode_cp != 127) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$unicode_cp > 31 and $unicode_cp != 127
MC/DC50%1/2
$unicode_cp > 31 and $unicode_cp != 127
$unicode_cp > 31
$unicode_cp != 127
Truth table66%2/3
A and B
A= $unicode_cp > 31B= $unicode_cp != 127
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | $tagname = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | require charnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | charnames::viacode($unicode_cp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | ▶ | $opts{displayname} //= $tagname // $unicode_cp_str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$opts{"displayname"} //= $tagname // $unicode_cp_str
$tagname // $unicode_cp_str
MC/DC0%0/3
$opts{"displayname"} //= $tagname // $unicode_cp_str
$opts{"displayname"}
$tagname
$unicode_cp_str
Truth table0%0/4
A //= B // C
A= $opts{"displayname"}B= $tagnameC= $unicode_cp_str
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 3 | $ret = Data::Identifier->new(unicodecp => $unicode_cp_str, displayname => $opts{displayname}, generator => WK_UNICODE_CHARACTER_GENERATOR, request => $unicode_cp_str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 3 | ▶ | $ret->_add_tagnames($tagname) if defined $tagname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 3 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 5 | ▶ | sub colour { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
colour: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 5 | my ($pkg, $colour, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 5 | $opts{request} = $colour; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 5 | $opts{generator} = WK_RGB_COLOUR_GENERATOR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 5 | return $pkg->generic(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 9 | ▶ | sub date { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date: called CC=35 SCAR=44.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 9 | my ($pkg, $request, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 9 | my ($year, $month, $day); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 9 | my $precision; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 9 | ▶ | if (ref($request)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if (eval {$request->can('epoch')}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $request = $request->epoch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | return $pkg->date(scalar($request->()), %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 9 | ($year, $month, $day) = $request =~ /^([12][0-9]{3})(?:-([01][0-9])(?:-([0-3][0-9]))?)?Z$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 9 | ▶ | unless (length($year // '') == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$year // ""
MC/DC100%1/1
$year // ""
$year
Truth table100%2/2
A
A= $year
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | ▶ | if ($request eq 'now' || $request eq 'today') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$request eq "now" or $request eq "today"
MC/DC0%0/2
$request eq "now" or $request eq "today"
$request eq "now"
$request eq "today"
Truth table33%1/3
A or B
A= $request eq "now"B= $request eq "today"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $request = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } elsif ($request =~ /^(?:0|-?[1-9][0-9]*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | $request = int($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 3 | ▶ | if ($request > 32503680000) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | croak 'Unlikely far date given. Likely miliseconds are passed as seconds?'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | croak 'Invalid format'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 3 | (undef,undef,undef,$day,$month,$year) = gmtime($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | $year += 1900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | $month += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 9 | foreach my $entry ($year, $month, $day) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 27 | ▶ | $entry = int($entry // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$entry // 0
MC/DC100%1/1
$entry // 0
$entry
Truth table100%2/2
A
A= $entry
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 9 | ▶ | croak 'Invalid year' if $year && ($year < 1583 || $year > 9999); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$year and $year < 1583 || $year > 9999
$year < 1583 or $year > 9999
MC/DC0%0/3
$year and $year < 1583 || $year > 9999
$year
$year < 1583
$year > 9999
Truth table25%1/4
A and B or C
A= $yearB= $year < 1583C= $year > 9999
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 9 | ▶ | croak 'Invalid month' if $month && ($month < 1 || $month > 12); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$month and $month < 1 || $month > 12
$month < 1 or $month > 12
MC/DC0%0/3
$month and $month < 1 || $month > 12
$month
$month < 1
$month > 12
Truth table50%2/4
A and B or C
A= $monthB= $month < 1C= $month > 12
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 9 | ▶ | croak 'Invalid day' if $day && ($day < 1 || $day > 31); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$day and $day < 1 || $day > 31
$day < 1 or $day > 31
MC/DC0%0/3
$day and $day < 1 || $day > 31
$day
$day < 1
$day > 31
Truth table50%2/4
A and B or C
A= $dayB= $day < 1C= $day > 31
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 9 | ▶ | $month = 0 unless $year; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 9 | ▶ | $day = 0 unless $month; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 9 | ▶ | $precision = $opts{precision} // ($day ? 'day' : undef) // ($month ? 'month' : undef) // 'year'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
(($opts{"precision"} // ($day ? "day" : undef)) // ($month ? "month" : undef)) // "year"
($opts{"precision"} // ($day ? "day" : undef)) // ($month ? "month" : undef)
$opts{"precision"} // ($day ? "day" : undef)
MC/DC0%0/1
(($opts{"precision"} // ($day ? "day" : undef)) // ($month ? "month" : undef)) // "year"
$opts{"precision"}
Truth table50%1/2
A
A= $opts{"precision"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 9 | ▶ | if ($precision eq 'day' && $day) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$precision eq "day" and $day
MC/DC50%1/2
$precision eq "day" and $day
$precision eq "day"
$day
Truth table66%2/3
A and B
A= $precision eq "day"B= $day
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 7 | $request = sprintf('%04u-%02u-%02uZ', $year, $month, $day); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | ▶ | } elsif ($precision eq 'month' && $month) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$precision eq "month" and $month
MC/DC50%1/2
$precision eq "month" and $month
$precision eq "month"
$month
Truth table66%2/3
A and B
A= $precision eq "month"B= $month
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | $request = sprintf('%04u-%02uZ', $year, $month); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ▶ | } elsif ($precision eq 'year' && $year) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$precision eq "year" and $year
MC/DC0%0/2
$precision eq "year" and $year
$precision eq "year"
$year
Truth table33%1/3
A and B
A= $precision eq "year"B= $year
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | $request = sprintf('%04uZ', $year); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | croak 'Bad precision: '.$precision; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 9 | $opts{request} = $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 9 | ▶ | $opts{input} //= $request; # force raw value! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"input"} //= $request
MC/DC0%0/2
$opts{"input"} //= $request
$opts{"input"}
$request
Truth table33%1/3
A //= B
A= $opts{"input"}B= $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 9 | $opts{style} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 9 | ▶ | $opts{tagname} //= $request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"tagname"} //= $request
MC/DC0%0/2
$opts{"tagname"} //= $request
$opts{"tagname"}
$request
Truth table33%1/3
A //= B
A= $opts{"tagname"}B= $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 9 | $opts{generator} = WK_DATE_GENERATOR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 9 | return $pkg->generic(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 8 | ▶ | sub language { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
language: called CC=7 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 8 | my ($pkg, $req, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 8 | my $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | my $identifier; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 8 | local $_; # Workaround invalid usage in earlier versions of I18N::LangTags::List | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # Fix https://github.com/Perl/perl5/pull/24697 was merged 2026-08-13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 8 | require I18N::LangTags::List; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 8 | $opts{request} = $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 8 | $opts{style} = 'id-based'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 8 | $opts{namespace} = '47dd950c-9089-4956-87c1-54c122533219'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | #$opts{generator} = WK_LANGUAGE_GENERATOR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 8 | ▶ | croak 'Bad language: '.$req unless I18N::LangTags::List::is_decent($req); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 8 | $name = I18N::LangTags::List::name($req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 8 | ▶ | unless (defined($name) && length($name)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and length $name
MC/DC0%0/2
defined $name and length $name
defined $name
length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | croak 'Bad language: '.$req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 8 | ▶ | $opts{displayname} //= $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"displayname"} //= $name
MC/DC0%0/2
$opts{"displayname"} //= $name
$opts{"displayname"}
$name
Truth table33%1/3
A //= B
A= $opts{"displayname"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 8 | $identifier = $pkg->generic(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 8 | ▶ | $identifier->{id_cache} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$identifier->{"id_cache"} //= {}
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table50%1/2
A
A= $identifier->{"id_cache"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 8 | ▶ | $identifier->{id_cache}->{'d0a4c6e2-ce2f-4d4c-b079-60065ac681f1'} //= $req; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$identifier->{"id_cache"}{"d0a4c6e2-ce2f-4d4c-b079-60065ac681f1"} //= $req
MC/DC0%0/2
$identifier->{"id_cache"}{"d0a4c6e2-ce2f-4d4c-b079-60065ac681f1"} //= $req
$identifier->{"id_cache"}{"d0a4c6e2-ce2f-4d4c-b079-60065ac681f1"}
$req
Truth table33%1/3
A //= B
A= $identifier->{"id_cache"}{"d0a4c6e2-ce2f-4d4c-b079-60065ac681f1"}B= $req
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 8 | return $identifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 8 | ▶ | sub multiplicity { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
multiplicity: called CC=9 SCAR=24.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 8 | my ($pkg, $subtype, $request, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 8 | ▶ | my $prefix = $_multiplicity_prefix{$subtype} // croak 'Invalid subtype: '.$subtype; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_multiplicity_prefix{$subtype} // croak('Invalid subtype: ' . $subtype)
MC/DC0%0/1
$_multiplicity_prefix{$subtype} // croak('Invalid subtype: ' . $subtype)
$_multiplicity_prefix{$subtype}
Truth table50%1/2
A
A= $_multiplicity_prefix{$subtype}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 8 | my $identifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | my $oid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 8 | ▶ | croak 'Invalid value: '.$request unless $request eq '0' || $request =~ /^[1-9][0-9]*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$request eq 0 or $request =~ /^[1-9][0-9]*$/u
MC/DC0%0/2
$request eq 0 or $request =~ /^[1-9][0-9]*$/u
$request eq 0
$request =~ /^[1-9][0-9]*$/u
Truth table66%2/3
A or B
A= $request eq 0B= $request =~ /^[1-9][0-9]*$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 8 | $oid = '1.3.6.1.4.1.46942.16.2.'.$prefix.'.'.$request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 8 | $opts{request} = $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 8 | $opts{input} = $prefix.'.'.$request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 8 | ▶ | $opts{displayname}//= $_multiplicity_names{$request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"displayname"} //= $_multiplicity_names{$request}
MC/DC0%0/2
$opts{"displayname"} //= $_multiplicity_names{$request}
$opts{"displayname"}
$_multiplicity_names{$request}
Truth table33%1/3
A //= B
A= $opts{"displayname"}B= $_multiplicity_names{$request}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 8 | ▶ | $opts{displayname}//= $request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"displayname"} //= $request
MC/DC0%0/2
$opts{"displayname"} //= $request
$opts{"displayname"}
$request
Truth table33%1/3
A //= B
A= $opts{"displayname"}B= $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 8 | $opts{generator} = $_multiplicity_generators{$subtype}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 8 | $identifier = $pkg->generic(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 8 | ▶ | $identifier->{id_cache} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$identifier->{"id_cache"} //= {}
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table50%1/2
A
A= $identifier->{"id_cache"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 8 | ▶ | $identifier->{id_cache}->{Data::Identifier->WK_OID} //= $oid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$identifier->{"id_cache"}{"Data::Identifier"->WK_OID} //= $oid
MC/DC0%0/2
$identifier->{"id_cache"}{"Data::Identifier"->WK_OID} //= $oid
$identifier->{"id_cache"}{"Data::Identifier"->WK_OID}
$oid
Truth table33%1/3
A //= B
A= $identifier->{"id_cache"}{"Data::Identifier"->WK_OID}B= $oid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 8 | ▶ | if (defined $_multiplicity_names{$request}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 8 | $identifier->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 8 | return $identifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | sub gte_simple { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gte_simple: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my ($pkg, $profile, $request, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my %order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | my $normal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | croak 'Called in list context' if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | $profile = $profile->ise if eval {$profile->can('ise')}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | $profile = $_gte_simple_profiles{$profile} // $profile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_gte_simple_profiles{$profile} // $profile
MC/DC0%0/2
$_gte_simple_profiles{$profile} // $profile
$_gte_simple_profiles{$profile}
$profile
Truth table0%0/3
A // B
A= $_gte_simple_profiles{$profile}B= $profile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | %order = map {$_ => $i++} split(//, $profile->{order}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if (defined(my $folding = $profile->{case_folding})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if ($folding eq 'none') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # no-op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } elsif ($folding eq 'upper') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $request = uc($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } elsif ($folding eq 'lower') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | $request = lc($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | croak 'Unsupported/invalid folding rule: '.$folding; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ($profile->{strip_slash}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $request =~ s#/+##g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ($profile->{strip_spaces}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $request =~ s#\s+##g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | $normal = join('', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | sort {$order{$a} <=> $order{$b}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | map {croak 'Invalid input element: '.$_ unless defined $order{$_}; $_} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | split //, $request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if (defined(my $info = delete $opts{info})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $info->{count} = length($normal); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $info->{request} = $normal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $opts{input} = $normal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $opts{request} = $normal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | $opts{namespace} //= $profile->{namespace}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"namespace"} //= $profile->{"namespace"}
MC/DC0%0/2
$opts{"namespace"} //= $profile->{"namespace"}
$opts{"namespace"}
$profile->{"namespace"}
Truth table0%0/3
A //= B
A= $opts{"namespace"}B= $profile->{"namespace"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | $opts{displayname}//= $normal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"displayname"} //= $normal
MC/DC0%0/2
$opts{"displayname"} //= $normal
$opts{"displayname"}
$normal
Truth table0%0/3
A //= B
A= $opts{"displayname"}B= $normal
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | return $pkg->generic(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 7 | ▶ | sub unit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 7 | my ($pkg, $request, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 7 | require Data::Identifier::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 7 | return Data::Identifier::Util->render_unit_request('Data::Identifier' => $request, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | sub digest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
digest: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my ($pkg, $type, $request, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | state $generator = Data::Identifier->new(uuid => WK_STD_DIGEST_ALGO_GENERATOR)->register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my Data::Identifier $identifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | my $utag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | croak 'Bad type or request' unless defined($type) && defined($request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $type and defined $request
MC/DC0%0/2
defined $type and defined $request
defined $type
defined $request
Truth table0%0/3
A and B
A= defined $typeB= defined $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $type = $type->ise if ref $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | if ($type eq 'utag' || $type eq '8db88212-69df-40f3-a5cf-105dcd853d44') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$type eq "utag" or $type eq "8db88212-69df-40f3-a5cf-105dcd853d44"
MC/DC0%0/2
$type eq "utag" or $type eq "8db88212-69df-40f3-a5cf-105dcd853d44"
$type eq "utag"
$type eq "8db88212-69df-40f3-a5cf-105dcd853d44"
Truth table0%0/3
A or B
A= $type eq "utag"B= $type eq "8db88212-69df-40f3-a5cf-105dcd853d44"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $utag = $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ▶ | } elsif (defined($_hash_type_to_utag{$type}) && defined($utag = $_hash_type_to_utag{$type}{$request})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $_hash_type_to_utag{$type} and defined($utag = $_hash_type_to_utag{$type}{$request})
MC/DC0%0/2
defined $_hash_type_to_utag{$type} and defined($utag = $_hash_type_to_utag{$type}{$request})
defined $_hash_type_to_utag{$type}
defined($utag = $_hash_type_to_utag{$type}{$request})
Truth table0%0/3
A and B
A= defined $_hash_type_to_utag{$type}B= defined($utag = $_hash_type_to_utag{$type}{$request})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # no-op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ▶ | } elsif (defined($_hash_type_to_utag{$_hash_type_aliases{$type} // '_nx'}) && defined($utag = $_hash_type_to_utag{$_hash_type_aliases{$type}}{$request})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
defined $_hash_type_to_utag{$_hash_type_aliases{$type} // "_nx"} and defined($utag = $_hash_type_to_utag{$_hash_type_aliases{$type}}{$request})
$_hash_type_aliases{$type} // "_nx"
MC/DC0%0/2
defined $_hash_type_to_utag{$_hash_type_aliases{$type} // "_nx"} and defined($utag = $_hash_type_to_utag{$_hash_type_aliases{$type}}{$request})
defined $_hash_type_to_utag{$_hash_type_aliases{$type} // "_nx"}
defined($utag = $_hash_type_to_utag{$_hash_type_aliases{$type}}{$request})
MC/DC0%0/1
$_hash_type_aliases{$type} // "_nx"
$_hash_type_aliases{$type}
Truth table0%0/3
A and B
A= defined $_hash_type_to_utag{$_hash_type_aliases{$type} // "_nx"}B= defined($utag = $_hash_type_to_utag{$_hash_type_aliases{$type}}{$request})
Truth table0%0/2
A
A= $_hash_type_aliases{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # no-op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | croak 'Invalid or unsupported type: '.$type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | croak 'Bad request: '.$utag unless $utag =~ /^[a-z]{2,6}-(?:0|[1-9][0-9]*)-[1-9][0-9]*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | $identifier = $pkg->generic(request => $utag, generator => $generator, tagname => $utag, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | $identifier->{generator} //= $generator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$identifier->{"generator"} //= $generator
MC/DC0%0/2
$identifier->{"generator"} //= $generator
$identifier->{"generator"}
$generator
Truth table0%0/3
A //= B
A= $identifier->{"generator"}B= $generator
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | $identifier->{request} //= $utag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$identifier->{"request"} //= $utag
MC/DC0%0/2
$identifier->{"request"} //= $utag
$identifier->{"request"}
$utag
Truth table0%0/3
A //= B
A= $identifier->{"request"}B= $utag
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | my $id_cache = $identifier->{id_cache} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$identifier->{"id_cache"} //= {}
MC/DC0%0/1
$identifier->{"id_cache"} //= {}
$identifier->{"id_cache"}
Truth table0%0/2
A
A= $identifier->{"id_cache"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | $id_cache->{'8db88212-69df-40f3-a5cf-105dcd853d44'} = $utag unless $identifier->type->eq('8db88212-69df-40f3-a5cf-105dcd853d44'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | foreach my $type (keys %_hash_utag_to_type) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | my $v = $_hash_utag_to_type{$type}{$utag} // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_hash_utag_to_type{$type}{$utag} // (next)
MC/DC0%0/1
$_hash_utag_to_type{$type}{$utag} // (next)
$_hash_utag_to_type{$type}{$utag}
Truth table0%0/2
A
A= $_hash_utag_to_type{$type}{$utag}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | $id_cache->{$type} //= $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$id_cache->{$type} //= $v
MC/DC0%0/2
$id_cache->{$type} //= $v
$id_cache->{$type}
$v
Truth table0%0/3
A //= B
A= $id_cache->{$type}B= $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return $identifier; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | #@returns Data::Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 225 | ▶ | sub generic { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generic: called CC=49 SCAR=56.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 225 | my ($pkg, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 225 | my $generator = $opts{generator}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 225 | ▶ | if (defined($generator)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 217 | ▶ | $generator = Data::Identifier->new(from => $generator) unless ref($generator); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 217 | ▶ | %opts = (%{$_generators{$generator->ise}//{}}, %opts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_generators{$generator->ise} // {}
MC/DC100%1/1
$_generators{$generator->ise} // {}
$_generators{$generator->ise}
Truth table100%2/2
A
A= $_generators{$generator->ise}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 225 | ▶ | if (defined(my $type = $opts{type})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | $opts{namespace} //= $type->namespace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"namespace"} //= $type->namespace
MC/DC0%0/2
$opts{"namespace"} //= $type->namespace
$opts{"namespace"}
$type->namespace
Truth table0%0/3
A //= B
A= $opts{"namespace"}B= $type->namespace
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 225 | ▶ | if (defined(my $style = $opts{style}) && defined(my $request = $opts{request})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined(my $style = $opts{"style"}) and defined(my $request = $opts{"request"})
MC/DC50%1/2
defined(my $style = $opts{"style"}) and defined(my $request = $opts{"request"})
defined(my $style = $opts{"style"})
defined(my $request = $opts{"request"})
Truth table66%2/3
A and B
A= defined(my $style = $opts{"style"})B= defined(my $request = $opts{"request"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 202 | ▶ | if ($style eq 'integer-based') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 98 | ▶ | croak 'Invalid request' unless $request =~ /^(?:0|-?[1-9][0-9]*)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 98 | ▶ | $opts{input} //= $request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"input"} //= $request
MC/DC0%0/2
$opts{"input"} //= $request
$opts{"input"}
$request
Truth table33%1/3
A //= B
A= $opts{"input"}B= $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } elsif ($style eq 'id-based') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 9 | my ($input, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 9 | ▶ | if (($input, $name) = $request =~ /^(#?[a-zA-Z0-9\-\.\+]+) (.+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # noop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } elsif (($input) = $request =~ /^(#?[a-zA-Z0-9\-\.\+]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 8 | $name = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | croak 'Invalid format, expected: "id name", or "id", got: '.$request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 9 | ▶ | $opts{input} //= lc($input); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"input"} //= lc $input
MC/DC0%0/1
$opts{"input"} //= lc $input
$opts{"input"}
Truth table50%1/2
A
A= $opts{"input"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 9 | ▶ | $opts{displayname} //= $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts{"displayname"} //= $name
MC/DC0%0/2
$opts{"displayname"} //= $name
$opts{"displayname"}
$name
Truth table66%2/3
A //= B
A= $opts{"displayname"}B= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } elsif ($style eq 'name-based') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 79 | ▶ | $opts{input} //= encode('UTF-8', $request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"input"} //= &encode("UTF-8", $request)
MC/DC0%0/2
$opts{"input"} //= &encode("UTF-8", $request)
$opts{"input"}
&encode("UTF-8", $request)
Truth table33%1/3
A //= B
A= $opts{"input"}B= &encode("UTF-8", $request)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 79 | ▶ | $opts{displayname} //= $request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts{"displayname"} //= $request
MC/DC0%0/2
$opts{"displayname"} //= $request
$opts{"displayname"}
$request
Truth table66%2/3
A //= B
A= $opts{"displayname"}B= $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } elsif ($style eq 'tag-based') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | if (ref($request)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $identifier = Data::Identifier->new(from => $request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | $opts{input} //= $identifier->uuid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"input"} //= $identifier->uuid
MC/DC0%0/2
$opts{"input"} //= $identifier->uuid
$opts{"input"}
$identifier->uuid
Truth table0%0/3
A //= B
A= $opts{"input"}B= $identifier->uuid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | $opts{displayname} //= $identifier->{displayname}; # steal the raw value here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"displayname"} //= $identifier->{"displayname"}
MC/DC0%0/2
$opts{"displayname"} //= $identifier->{"displayname"}
$opts{"displayname"}
$identifier->{"displayname"}
Truth table0%0/3
A //= B
A= $opts{"displayname"}B= $identifier->{"displayname"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } elsif ($request =~ Data::Identifier->RE_UUID) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | $opts{input} //= $request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"input"} //= $request
MC/DC0%0/2
$opts{"input"} //= $request
$opts{"input"}
$request
Truth table0%0/3
A //= B
A= $opts{"input"}B= $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | croak 'Invalid format for tag-based generator: '.$request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } elsif ($style eq 'tagcombiner') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | if (ref($request) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my %uuids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | foreach my $entry (@{$request}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | if (ref($entry)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $uuids{Data::Identifier->new(from => $entry)->uuid} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } elsif ($entry =~ Data::Identifier->RE_UUID) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $uuids{$entry} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | croak 'Invalid format for tag-based generator: '.$entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | croak 'Less than two tags being combined' unless scalar(keys %uuids) > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | $opts{input} //= join(',', sort keys %uuids); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"input"} //= join(",", sort(keys %uuids))
MC/DC0%0/1
$opts{"input"} //= join(",", sort(keys %uuids))
$opts{"input"}
Truth table0%0/2
A
A= $opts{"input"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | croak 'Invalid request for tagcombiner generator: '.$request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } elsif ($style eq 'colour') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 16 | ▶ | if (defined $request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 16 | my $req = lc($request); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 16 | ▶ | if (exists &Data::URIID::Colour::new) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | eval { $opts{displaycolour} //= Data::URIID::Colour->new(rgb => $request) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"displaycolour"} //= "Data::URIID::Colour"->new("rgb", $request)
MC/DC0%0/2
$opts{"displaycolour"} //= "Data::URIID::Colour"->new("rgb", $request)
$opts{"displaycolour"}
"Data::URIID::Colour"->new("rgb", $request)
Truth table0%0/3
A //= B
A= $opts{"displaycolour"}B= "Data::URIID::Colour"->new("rgb", $request)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # Ensure our requests are always in standard format, at least for now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 16 | ▶ | delete $opts{request} if length($request) != 7; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 16 | ▶ | $req = sprintf('#%s%s%s', $1 x 6, $2 x 6, $3 x 6) if $req =~ /^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 16 | ▶ | $req = sprintf('#%s%s%s', $1 x 3, $2 x 3, $3 x 3) if $req =~ /^#([a-f0-9]{4})([a-f0-9]{4})([a-f0-9]{4})$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 16 | ▶ | if ($req =~ /^#[a-f0-9]{36}$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 16 | ▶ | $opts{input} //= $req; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"input"} //= $req
MC/DC0%0/2
$opts{"input"} //= $req
$opts{"input"}
$req
Truth table33%1/3
A //= B
A= $opts{"input"}B= $req
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | croak 'Bad format for colour'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | croak 'Style not supported: '.$style; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 225 | ▶ | croak 'No valid style/request or input is provided' unless defined $opts{input}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 224 | ▶ | my $ns = ref($opts{namespace}) ? $opts{namespace}->uuid(no_defaults => 1) : $opts{namespace}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 224 | my $uuid = $pkg->_uuid_v5($ns, $opts{input}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 224 | my $tag = Data::Identifier->new(uuid => $uuid, displayname => $opts{displayname}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 224 | foreach my $key (qw(request displaycolour description icontext displayname)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1120 | ▶ | $tag->{$key} //= $opts{$key} if defined $opts{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tag->{$key} //= $opts{$key}
MC/DC0%0/2
$tag->{$key} //= $opts{$key}
$tag->{$key}
$opts{$key}
Truth table66%2/3
A //= B
A= $tag->{$key}B= $opts{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | $tag->_add_tagnames(ref $opts{tagname} ? @{$opts{tagname}} : $opts{tagname}) if defined $opts{tagname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 224 | ▶ | $tag->{generator} //= $generator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$tag->{"generator"} //= $generator
MC/DC100%2/2
$tag->{"generator"} //= $generator
$tag->{"generator"}
$generator
Truth table100%3/3
A //= B
A= $tag->{"generator"}B= $generator
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 224 | return $tag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | # ---- Private helpers ---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1 | ▶ | sub _register_generator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_generator: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | my ($pkg, $generator, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | ▶ | my $g = $_generators{$generator->ise} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_generators{$generator->ise} //= {}
MC/DC0%0/1
$_generators{$generator->ise} //= {}
$_generators{$generator->ise}
Truth table50%1/2
A
A= $_generators{$generator->ise}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | foreach my $key (keys %opts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 3 | ▶ | my $v = $opts{$key} // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{$key} // (next)
MC/DC100%1/1
$opts{$key} // (next)
$opts{$key}
Truth table100%2/2
A
A= $opts{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | ▶ | $g->{$key} //= $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$g->{$key} //= $v
MC/DC0%0/2
$g->{$key} //= $v
$g->{$key}
$v
Truth table33%1/3
A //= B
A= $g->{$key}B= $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | sub _available_module { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_available_module: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my (@modules) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | state $tried = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | foreach my $module (@modules) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | if (exists $tried->{$module}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | next unless $tried->{$module}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | return $module; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $res = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $modname = $module =~ s#::#/#gr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | require $modname.'.pm'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $tried->{$module} = $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | return $module if $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | croak 'Found none of modules ['.join(', ', @modules).']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 583 | ▶ | sub _finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 583 | my ($raw, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 583 | substr($raw, 6, 1, chr((ord(substr($raw, 6, 1)) & 0x0F) | ($version << 4))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 583 | substr($raw, 8, 1, chr((ord(substr($raw, 8, 1)) & 0x3F) | 0x80)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 583 | return join('-', unpack('H8H4H4H4H12', $raw)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | sub _random { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_random: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | my ($pkg, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | my $sources = $opts{sources} // (state $default_sources = [qw(Crypt::URandom UUID4::Tiny Math::Random::Secure UUID::URandom UUID::Tiny::Patch::UseMRS)]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{"sources"} // (state $default_sources = ["Crypt::URandom", "UUID4::Tiny", "Math::Random::Secure", "UUID::URandom", "UUID::Tiny::Patch::UseMRS"])
MC/DC0%0/2
$opts{"sources"} // (state $default_sources = ["Crypt::URandom", "UUID4::Tiny", "Math::Random::Secure", "UUID::URandom", "UUID::Tiny::Patch::UseMRS"])
$opts{"sources"}
(state $default_sources = ["Crypt::URandom", "UUID4::Tiny", "Math::Random::Secure", "UUID::URandom", "UUID::Tiny::Patch::UseMRS"])
Truth table0%0/3
A // B
A= $opts{"sources"}B= (state $default_sources = ["Crypt::URandom", "UUID4::Tiny", "Math::Random::Secure", "UUID::URandom", "UUID::Tiny::Patch::UseMRS"])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my $source = _available_module(@{$sources}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my $raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # Secure: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | if ($source eq 'Crypt::URandom') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | $raw = Crypt::URandom::urandom(16); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } elsif ($source eq 'UUID4::Tiny') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | return UUID4::Tiny::create_uuid_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } elsif ($source eq 'Math::Random::Secure') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | $raw = join('', map {chr Math::Random::Secure::irand(256)} 0..15); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } elsif ($source eq 'UUID::URandom') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | return UUID::URandom::create_uuid_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } elsif ($source eq 'UUID::Tiny::Patch::UseMRS') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | return UUID::Tiny::create_uuid_as_string(UUID::Tiny::UUID_RANDOM()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | # Insecure: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } elsif ($source eq 'UUID::Tiny') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | return UUID::Tiny::create_uuid_as_string(UUID::Tiny::UUID_RANDOM()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } elsif ($source eq 'Data::UUID') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | require Data::UUID; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | return Data::UUID->create_str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | #} elsif ($source eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | croak 'Invalid/unsupported source'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | if (defined($raw) && length($raw) == 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $raw and length $raw == 16
MC/DC0%0/2
defined $raw and length $raw == 16
defined $raw
length $raw == 16
Truth table0%0/3
A and B
A= defined $rawB= length $raw == 16
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | return _finish($raw, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | croak 'Bug!'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 583 | ▶ | sub _uuid_v5 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uuid_v5: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 583 | my ($pkg, $ns, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 583 | my $digest = Digest->new('SHA-1'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 583 | ▶ | $ns = $ns->uuid(no_defaults => 1) if ref $ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 583 | $ns = pack('H*', $ns =~ tr/-//dr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 583 | ▶ | croak 'Invalid namespace given' unless length($ns) == 16; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 583 | $digest->add($ns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 583 | $digest->add($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 583 | return _finish(substr($digest->digest, 0, 16), 5); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||