| 1 | package Test2::Harness::UI::UUID; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use overload( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | fallback => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 421 | ▶ | '""' => sub { $_[0]->magic_stringify }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 659 | ▶ | bool => sub { 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use Data::UUID; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use Scalar::Util qw/blessed reftype/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use Test2::Harness::Util qw/looks_like_uuid/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use Test2::Harness::Util::UUID qw/UG/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 10 | require Test2::Harness::Util::UUID; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 10 | require bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 10 | ▶ | use Importer Importer => 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 10 | our @EXPORT_OK = qw/uuid_inflate uuid_deflate gen_uuid gen_deflated_uuid uuid_mass_inflate uuid_mass_deflate looks_like_uuid_36_or_16/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 7 | ▶ | sub gen_uuid { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_uuid: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | my $binary = UG()->create(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 7 | my $forsql = _reorder_bin($binary); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | my $string = UG()->to_string($binary); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | return bless( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | binary => $forsql, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | string => lc($string), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | __PACKAGE__ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # gen_uuid() builds both forms of the id and blesses them. A row headed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # straight for the database needs only the stored form. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub gen_deflated_uuid { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_deflated_uuid: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $binary = UG()->create(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | return _reorder_bin($binary) if $Test2::Harness::UI::Schema::LOADED && $Test2::Harness::UI::Schema::LOADED =~ m/mysql/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Test2::Harness::UI::Schema::LOADED and $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
MC/DC0%0/2
$Test2::Harness::UI::Schema::LOADED and $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
$Test2::Harness::UI::Schema::LOADED
$Test2::Harness::UI::Schema::LOADED =~ /mysql/i
Truth table0%0/3
A and B
A= $Test2::Harness::UI::Schema::LOADEDB= $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return lc(UG()->to_string($binary)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my ($val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | $val //= lc(Test2::Harness::Util::UUID::gen_uuid()); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$val //= lc Test2::Harness::Util::UUID::gen_uuid()
MC/DC0%0/1
$val //= lc Test2::Harness::Util::UUID::gen_uuid()
$val
Truth table0%0/2
A
A= $val
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return uuid_inflate($val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 87 | ▶ | sub _reorder_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reorder_bin: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 87 | my $bin = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 87 | return join '' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | scalar(reverse(substr($bin, 6, 2))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | scalar(reverse(substr($bin, 4, 2))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | scalar(reverse(substr($bin, 0, 4))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | substr($bin, 8, 8), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 66 | ▶ | sub _unorder_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unorder_bin: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 66 | my ($bin) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 66 | return join '' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | scalar(reverse(substr($bin, 4, 4))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | scalar(reverse(substr($bin, 2, 2))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | scalar(reverse(substr($bin, 0, 2))), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | substr($bin, 8, 8), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 219 | ▶ | sub uuid_inflate { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uuid_inflate: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 219 | my ($val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 219 | ▶ | return undef unless $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 210 | ▶ | return $val if blessed($val) && $val->isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($val) and $val->isa(__PACKAGE__)
MC/DC50%1/2
builtin::blessed($val) and $val->isa(__PACKAGE__)
builtin::blessed($val)
$val->isa(__PACKAGE__)
Truth table66%2/3
A and B
A= builtin::blessed($val)B= $val->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 158 | my $size = bytes::length($val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 158 | my $out; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 158 | ▶ | if ($size == 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 66 | my $unbin = UG()->to_string(_unorder_bin($val)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 66 | $out = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | string => lc($unbin), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | binary => $val, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | elsif ($size == 36) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 80 | $val = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 80 | my $bin = UG()->from_string($val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 80 | $out = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | string => lc($val), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | binary => _reorder_bin($bin), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 158 | ▶ | return undef unless $out; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 146 | return bless($out, __PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 421 | ▶ | sub magic_stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
magic_stringify: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 421 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 421 | ▶ | return $self->{string} unless $Test2::Harness::UI::Schema::LOADED && $Test2::Harness::UI::Schema::LOADED =~ m/mysql/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Test2::Harness::UI::Schema::LOADED and $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
MC/DC100%2/2
$Test2::Harness::UI::Schema::LOADED and $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
$Test2::Harness::UI::Schema::LOADED
$Test2::Harness::UI::Schema::LOADED =~ /mysql/i
Truth table100%3/3
A and B
A= $Test2::Harness::UI::Schema::LOADEDB= $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 209 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 209 | ▶ | while (my @call = caller($i++)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 627 | ▶ | return $self->{binary} if $call[0] =~ m/DBIx::Class::Storage::DBI/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 627 | ▶ | return $self->{string} if $i > 2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $self->{string}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 140 | ▶ | sub uuid_deflate { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uuid_deflate: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 140 | my ($val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 140 | ▶ | return undef unless $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 131 | ▶ | $val = uuid_inflate($val) unless blessed($val) && $val->isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($val) and $val->isa(__PACKAGE__)
MC/DC50%1/2
builtin::blessed($val) and $val->isa(__PACKAGE__)
builtin::blessed($val)
$val->isa(__PACKAGE__)
Truth table66%2/3
A and B
A= builtin::blessed($val)B= $val->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 131 | ▶ | return undef unless $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 125 | ▶ | return $val->{binary} if $Test2::Harness::UI::Schema::LOADED && $Test2::Harness::UI::Schema::LOADED =~ m/mysql/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Test2::Harness::UI::Schema::LOADED and $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
MC/DC50%1/2
$Test2::Harness::UI::Schema::LOADED and $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
$Test2::Harness::UI::Schema::LOADED
$Test2::Harness::UI::Schema::LOADED =~ /mysql/i
Truth table66%2/3
A and B
A= $Test2::Harness::UI::Schema::LOADEDB= $Test2::Harness::UI::Schema::LOADED =~ /mysql/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 62 | return $val->{string}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 10 | *deflate = \&uuid_deflate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 10 | *inflate = \&uuid_inflate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 33 | ▶ | sub binary { $_[0]->{binary} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 53 | ▶ | sub string { $_[0]->{string} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub TO_JSON { $_[0]->{string} } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | ▶ | sub uuid_mass_inflate { _uuid_mass_flate($_[0], \&uuid_inflate, \&uuid_mass_inflate) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uuid_mass_inflate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 6 | ▶ | sub uuid_mass_deflate { _uuid_mass_flate($_[0], \&uuid_deflate, \&uuid_mass_deflate) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uuid_mass_deflate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 372 | ▶ | sub _uuid_mass_flate { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uuid_mass_flate: called CC=21 SCAR=30.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 372 | my ($val_do_not_use, $flate, $mass_flate) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 372 | ▶ | return $_[0] unless $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 372 | ▶ | if (blessed($_[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 104 | ▶ | return $_[0] = $flate->($_[0]) if $_[0]->isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 268 | ▶ | return $_[0] = $flate->($_[0]) if looks_like_uuid_36_or_16($_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 132 | ▶ | my $type = reftype($_[0]) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 132 | ▶ | if ($type eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | my @list = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 252 | my $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 252 | ▶ | $ok &&= $_ eq 'owner' || (m/_(id|key)$/ && $_ ne 'trace_id'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition77%7/9
$ok &&= $_ eq "owner" || /_(id|key)$/ && $_ ne "trace_id"
$_ eq 'owner' || /_(id|key)$/ && $_ ne 'trace_id'
/_(id|key)$/ and $_ ne "trace_id"
MC/DC0%0/4
$ok &&= $_ eq "owner" || /_(id|key)$/ && $_ ne "trace_id"
$ok
$_ eq 'owner'
/_(id|key)$/
$_ ne "trace_id"
Truth table0%0/5
A &&= B || C and D
A= $okB= $_ eq 'owner'C= /_(id|key)$/D= $_ ne "trace_id"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 252 | ▶ | $ok &&= looks_like_uuid_36_or_16($_[0]->{$_}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ok &&= looks_like_uuid_36_or_16($_[0]{$_})
MC/DC50%1/2
$ok &&= looks_like_uuid_36_or_16($_[0]{$_})
$ok
looks_like_uuid_36_or_16($_[0]{$_})
Truth table66%2/3
A &&= B
A= $okB= looks_like_uuid_36_or_16($_[0]{$_})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 252 | ▶ | my $rt = reftype($_[0]->{$_}) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
builtin::reftype($_[0]{$_}) // ""
MC/DC100%1/1
builtin::reftype($_[0]{$_}) // ""
builtin::reftype($_[0]{$_})
Truth table100%2/2
A
A= builtin::reftype($_[0]{$_})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 252 | ▶ | $ok ||= $rt eq 'HASH' || $rt eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$ok ||= $rt eq "HASH" || $rt eq "ARRAY"
$rt eq 'HASH' || $rt eq 'ARRAY'
MC/DC0%0/3
$ok ||= $rt eq "HASH" || $rt eq "ARRAY"
$ok
$rt eq 'HASH'
$rt eq 'ARRAY'
Truth table0%0/4
A ||= B || C
A= $okB= $rt eq 'HASH'C= $rt eq 'ARRAY'
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 252 | $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 48 | } keys %{$_[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 48 | $_[0]->{$_} = _uuid_mass_flate($_[0]->{$_}, $flate, $mass_flate) for @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | elsif($type eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 84 | $_ = _uuid_mass_flate($_, $flate, $mass_flate) for grep { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 168 | my $ok = looks_like_uuid_36_or_16($_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 168 | ▶ | my $dt = reftype($_) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
builtin::reftype($_) // ""
MC/DC100%1/1
builtin::reftype($_) // ""
builtin::reftype($_)
Truth table100%2/2
A
A= builtin::reftype($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 168 | ▶ | $ok ||= 1 if $dt eq 'HASH' || $dt eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
$dt eq "HASH" or $dt eq "ARRAY"
$ok ||= 1
MC/DC100%2/2
$dt eq "HASH" or $dt eq "ARRAY"
$dt eq "HASH"
$dt eq "ARRAY"
MC/DC100%1/1
$ok ||= 1
$ok
Truth table100%3/3
A or B
A= $dt eq "HASH"B= $dt eq "ARRAY"
Truth table100%2/2
A
A= $ok
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 168 | $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 84 | } @{$_[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 132 | return $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 561 | ▶ | sub looks_like_uuid_36_or_16 { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
looks_like_uuid_36_or_16: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 561 | my ($val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 561 | ▶ | return 0 unless $val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 561 | my $len = length($val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 561 | ▶ | if ($len == 16) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 135 | ▶ | return 1 if $val !~ m/^[[:ascii:]]+$/s; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 14 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | elsif ($len == 36) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 270 | ▶ | return unless $val =~ m/-/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 258 | return looks_like_uuid($val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 156 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||