| 1 | package UUID::Object; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | our $VERSION = '0.81'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | *import = \&Exporter::import; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||
| 13 | uuid_nil | ||||||||||||||||||||||||||||||||||||||||||
| 14 | uuid_ns_dns | ||||||||||||||||||||||||||||||||||||||||||
| 15 | uuid_ns_url | ||||||||||||||||||||||||||||||||||||||||||
| 16 | uuid_ns_oid | ||||||||||||||||||||||||||||||||||||||||||
| 17 | uuid_ns_x500 | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 10 | ▶ | use POSIX qw( floor ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 10 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 10 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 10 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | q{""} => sub { $_[0]->as_string }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 10 | q{<=>} => \&_compare, | |||||||||||||||||||||||||||||||||||||||||
| 27 | q{cmp} => \&_compare, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | fallback => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 10 | ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 13 | ▶ | sub _compare { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compare: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 13 | my ($a, $b) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 13 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 13 | ▶ | if (eval { $b->isa(__PACKAGE__) }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 11 | return $$a cmp $$b; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | # compare with bare string | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | ▶ | if (! ref $b) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | $b = __PACKAGE__->create_from_string($b); | |||||||||||||||||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | if (! $@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | return $$a cmp $$b; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | my $data = $$self; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | my $result = \$data; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | return bless $result, ref $self; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 82 | ▶ | sub create_nil { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_nil: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 82 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 82 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 82 | my $data = chr(0) x 16; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 82 | my $self = \$data; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 82 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | ▶ | sub create { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | my $self = $class->create_nil(); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | $self->assign(@_); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 10 | *new = *create; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | sub create_from_binary { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_from_binary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my ($class, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | my $self = \$arg; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub create_from_binary_np { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_from_binary_np: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $self = $class->create_nil(); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $self->assign_with_binary_np(@_); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | sub create_from_hex { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_from_hex: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | my $self = $class->create_nil(); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $self->assign_with_hex(@_); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 62 | ▶ | sub create_from_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_from_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 62 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 62 | my $self = $class->create_nil(); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 62 | $self->assign_with_string(@_); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 62 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | ▶ | sub create_from_base64 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_from_base64: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | my $self = $class->create_nil(); | |||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | $self->assign_with_base64(@_); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub create_from_base64_np { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_from_base64_np: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $self = $class->create_nil(); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $self->assign_with_base64_np(@_); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | sub create_from_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_from_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | my $self = $class->create_nil(); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | $self->assign_with_hash(@_); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 9 | ▶ | sub assign { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign: called CC=9 SCAR=23.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 9 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 9 | ▶ | if (! defined $arg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | $self->assign_with_object($self->create_nil); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 8 | elsif (eval { $arg->isa(ref $self) }) { | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $self->assign_with_object($arg); | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | ▶ | elsif (! ref $arg && ! @_) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $arg || @_
MC/DC0%0/2
ref $arg || @_
ref $arg
@_
Truth table33%1/3
A || B
A= ref $argB= @_
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 8 | ▶ | if (length $arg == 16) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | $self->assign_with_binary($arg); | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | elsif ($arg =~ m{ \A [0-9a-f]{32} \z }ixmso) { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | $self->assign_with_hex($arg); | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | elsif ($arg =~ m{ \A [0-9a-f]{8} (?: - [0-9a-f]{4} ){3} | ||||||||||||||||||||||||||||||||||||||||||
| 144 | - [0-9a-f]{12} \z }ixmso) { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | $self->assign_with_string($arg); | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | elsif ($arg =~ m{ \A [+/0-9A-Za-z]{22} == \z }xmso) { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | $self->assign_with_base64($arg); | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | croak "invalid format"; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | unshift @_, $arg; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $self->assign_with_hash(@_); | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | ▶ | sub assign_with_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_with_object: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | ▶ | if (! eval { $arg->isa(ref $self) }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | croak "argument must be UUID::Object"; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | $$self = $$arg; | |||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 77 | ▶ | sub assign_with_binary { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_with_binary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 77 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 77 | $$self = q{} . $arg; | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 77 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | sub assign_with_binary_np { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_with_binary_np: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | substr $arg, 0, 4, | |||||||||||||||||||||||||||||||||||||||||
| 186 | pack('N', unpack('I', substr($arg, 0, 4))); | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | substr $arg, 4, 2, | |||||||||||||||||||||||||||||||||||||||||
| 189 | pack('n', unpack('S', substr($arg, 4, 2))); | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | substr $arg, 6, 2, | |||||||||||||||||||||||||||||||||||||||||
| 192 | pack('n', unpack('S', substr($arg, 6, 2))); | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $$self = q{} . $arg; | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 69 | ▶ | sub assign_with_hex { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_with_hex: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 69 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 69 | ▶ | if ($arg !~ m{ \A [0-9a-f]{32} \z }ixmso) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | croak "invalid format"; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 69 | return $self->assign_with_binary(pack 'H*', $arg); | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 65 | ▶ | sub assign_with_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_with_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 65 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 65 | $arg =~ tr{-}{}d; | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 65 | return $self->assign_with_hex($arg); | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 5 | ▶ | sub assign_with_base64 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_with_base64: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 5 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | ▶ | if ($arg !~ m{ \A [+/0-9A-Za-z]{22} == \z }xmso) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | croak "invalid format"; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 5 | return $self->assign_with_binary(decode_base64($arg)); | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub assign_with_base64_np { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_with_base64_np: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if ($arg !~ m{ \A [+/0-9A-Za-z]{22} == \z }xmso) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | croak "invalid format"; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return $self->assign_with_binary_np(decode_base64($arg)); | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | sub assign_with_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assign_with_hash: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | ▶ | my $arg = @_ && ref $_[0] eq 'HASH' ? shift : { @_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | if (my $variant = delete $arg->{variant}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | $self->variant($variant); | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | foreach my $key (qw( version | |||||||||||||||||||||||||||||||||||||||||
| 246 | time time_low time_mid time_hi | ||||||||||||||||||||||||||||||||||||||||||
| 247 | clk_seq node )) { | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 14 | ▶ | if (exists $arg->{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 6 | $self->$key($arg->{$key}); | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 27 | ▶ | sub as_binary { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_binary: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 27 | return ${$_[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | sub as_binary_np { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_binary_np: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my $r = $self->as_binary; | |||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | substr $r, 0, 4, | |||||||||||||||||||||||||||||||||||||||||
| 266 | pack('I', unpack('N', substr($r, 0, 4))); | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | substr $r, 4, 2, | |||||||||||||||||||||||||||||||||||||||||
| 269 | pack('S', unpack('n', substr($r, 4, 2))); | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | substr $r, 6, 2, | |||||||||||||||||||||||||||||||||||||||||
| 272 | pack('S', unpack('n', substr($r, 6, 2))); | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | ▶ | sub as_hex { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hex: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | return scalar unpack 'H*', ${$_[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 26 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 26 | my $u = $_[0]->as_binary; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 130 | return join q{-}, map { unpack 'H*', $_ } | |||||||||||||||||||||||||||||||||||||||||
| 284 | 26 | map { substr $u, 0, $_, q{} } | |||||||||||||||||||||||||||||||||||||||||
| 285 | ( 4, 2, 2, 2, 6 ); | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | ▶ | sub as_base64 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_base64: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | my $r = encode_base64(${$_[0]}); | |||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | $r =~ s{\s+}{}gxmso; | |||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | return $r; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | sub as_base64_np { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_base64_np: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $data = ${$_[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | substr $data, 0, 4, | |||||||||||||||||||||||||||||||||||||||||
| 300 | pack('I', unpack('N', substr($data, 0, 4))); | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | substr $data, 4, 2, | |||||||||||||||||||||||||||||||||||||||||
| 303 | pack('S', unpack('n', substr($data, 4, 2))); | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | substr $data, 6, 2, | |||||||||||||||||||||||||||||||||||||||||
| 306 | pack('S', unpack('n', substr($data, 6, 2))); | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $r = encode_base64($data); | |||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $r =~ s{\s+}{}gxmso; | |||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | sub as_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $r = {}; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | foreach my $key (qw( variant version | |||||||||||||||||||||||||||||||||||||||||
| 319 | time_low time_mid time_hi | ||||||||||||||||||||||||||||||||||||||||||
| 320 | clk_seq node )) { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $r->{$key} = $self->$key(); | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | sub as_urn { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_urn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return 'urn:uuid:' . $self->as_string; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 49 | ▶ | sub variant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
variant: called CC=8 SCAR=22.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 49 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 49 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | my $var = shift; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 3 | ▶ | if ($var !~ m{^\d+$}o || ! grep { $var == $_ } qw( 0 2 6 7 4 )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$var =~ /^\d+$/o and grep {$var == $_;} 0, 2, 6, 7, 4
MC/DC0%0/2
$var =~ /^\d+$/o and grep {$var == $_;} 0, 2, 6, 7, 4
$var =~ /^\d+$/o
grep {$var == $_;} 0, 2, 6, 7, 4
Truth table33%1/3
A and B
A= $var =~ /^\d+$/oB= grep {$var == $_;} 0, 2, 6, 7, 4
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | croak "invalid parameter"; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | ▶ | $var = 2 if $var == 4; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | ▶ | if ($var == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | substr $$self, 8, 1, | |||||||||||||||||||||||||||||||||||||||||
| 346 | chr(ord(substr $$self, 8, 1) & 0x7f); | ||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | elsif ($var < 3) { | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | substr $$self, 8, 1, | |||||||||||||||||||||||||||||||||||||||||
| 350 | chr(ord(substr $$self, 8, 1) & 0x3f | $var << 6); | ||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | substr $$self, 8, 1, | |||||||||||||||||||||||||||||||||||||||||
| 354 | chr(ord(substr $$self, 8, 1) & 0x1f | $var << 5); | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 3 | return $var; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 46 | my $var = (ord(substr $$self, 8, 1) & 0xe0) >> 5; | |||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 46 | my %varmap = ( 1 => 0, 2 => 0, 3 => 0, 4 => 2, 5 => 2, ); | |||||||||||||||||||||||||||||||||||||||||
| 363 | 46 | ▶ | if (exists $varmap{$var}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 35 | $var = $varmap{$var}; | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 46 | return $var; | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 58 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=5 SCAR=17.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 58 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 58 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 7 | my $ver = shift; | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 7 | ▶ | if ($ver !~ m{^\d+$}o || $ver < 0 || $ver > 15) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $ver =~ /^\d+$/o or $ver < 0 or $ver > 15
not $ver =~ /^\d+$/o or $ver < 0
MC/DC0%0/3
not $ver =~ /^\d+$/o or $ver < 0 or $ver > 15
not $ver =~ /^\d+$/o
$ver < 0
$ver > 15
Truth table25%1/4
not(A) or B or C
A= not $ver =~ /^\d+$/oB= $ver < 0C= $ver > 15
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | croak "invalid parameter"; | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 7 | substr $$self, 6, 1, | |||||||||||||||||||||||||||||||||||||||||
| 381 | chr(ord(substr($$self, 6, 1)) & 0x0f | $ver << 4); | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 7 | return $ver; | |||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 51 | return (ord(substr($$self, 6, 1)) & 0xf0) >> 4; | |||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 8 | ▶ | sub time_low { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time_low: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 8 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 3 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 3 | substr $$self, 0, 4, pack('N', $arg); | |||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 3 | return $arg; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 5 | return unpack 'N', substr($$self, 0, 4); | |||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 11 | ▶ | sub time_mid { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time_mid: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 11 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 11 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 4 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 4 | substr $$self, 4, 2, pack('n', $arg); | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 4 | return $arg; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 7 | return unpack 'n', substr($$self, 4, 2); | |||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 8 | ▶ | sub time_hi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time_hi: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 8 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 3 | ▶ | if ($arg >= 0x1000) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | croak "invalid parameter"; | |||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | substr $$self, 6, 2, | |||||||||||||||||||||||||||||||||||||||||
| 428 | pack('n', unpack('n', substr($$self, 6, 2)) & 0xf000 | ||||||||||||||||||||||||||||||||||||||||||
| 429 | | $arg); | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | return $arg; | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 5 | return unpack('n', substr($$self, 6, 2)) & 0x0fff; | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | ▶ | sub clk_seq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clk_seq: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 3 | my $r = unpack 'n', substr($$self, 8, 2); | |||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 3 | my $v = $r >> 13; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 3 | ▶ | my $w = ($v >= 6) ? 3 # 11x | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | : ($v >= 4) ? 2 # 10- | ||||||||||||||||||||||||||||||||||||||||||
| 445 | : 1; # 0-- | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | 3 | $w = 16 - $w; | |||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 3 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | ▶ | if ($arg < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | croak "invalid parameter"; | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 2 | $arg &= ((1 << $w) - 1); | |||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | substr $$self, 8, 2, | |||||||||||||||||||||||||||||||||||||||||
| 459 | pack('n', $r & (0xffff - ((1 << $w) - 1)) | $arg); | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 2 | return $arg; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 1 | return $r & ((1 << $w) - 1); | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 3 | ▶ | sub node { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node: called CC=6 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 3 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 2 | ▶ | if (length $arg == 6) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | elsif (length $arg == 12) { | ||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $arg = pack 'H*', $arg; | |||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | elsif (length $arg == 17) { | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 2 | ▶ | if ($arg !~ m{ \A (?: [0-9A-F]{2} ) ([-:]) [0-9A-F]{2} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | (?: \1 [0-9A-F]{2} ){4} | ||||||||||||||||||||||||||||||||||||||||||
| 481 | \z }ixmso) { | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | croak "invalid parameter"; | |||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 2 | $arg =~ tr{-:}{}d; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 2 | $arg = pack 'H*', $arg; | |||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | croak "invalid parameter"; | |||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 2 | substr $$self, 10, 6, $arg; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 3 | return join q{:}, map { uc unpack 'H*', $_ } | |||||||||||||||||||||||||||||||||||||||||
| 496 | split q{}, substr $$self, 10, 6; | ||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 1 | ▶ | sub _set_time { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_time: called CC=3 SCAR=11.5
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 1 | my ($self, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | # hi = time mod (1000000 / 0x100000000) | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | my $hi = floor($arg / 65536.0 / 512 * 78125); | |||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | $arg -= $hi * 512.0 * 65536 / 78125; | |||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | my $low = floor($arg * 10000000.0 + 0.5); | |||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | # MAGIC offset: 01B2-1DD2-13814000 | ||||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | ▶ | if ($low < 0xec7ec000) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | $low += 0x13814000; | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $low -= 0xec7ec000; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $hi ++; | |||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | ▶ | if ($hi < 0x0e4de22e) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 1 | $hi += 0x01b21dd2; | |||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $hi -= 0x0e4de22e; # wrap around | |||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | 1 | $self->time_low($low); | |||||||||||||||||||||||||||||||||||||||||
| 525 | 1 | $self->time_mid($hi & 0xffff); | |||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | $self->time_hi(($hi >> 16) & 0x0fff); | |||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 4 | ▶ | sub time { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time: called CC=4 SCAR=14.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 4 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 1 | $self->_set_time(@_); | |||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 4 | my $low = $self->time_low; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 4 | my $hi = $self->time_mid | ($self->time_hi << 16); | |||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | # MAGIC offset: 01B2-1DD2-13814000 | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 4 | ▶ | if ($low >= 0x13814000) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | 4 | $low -= 0x13814000; | |||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||
| 545 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $low += 0xec7ec000; | |||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | $hi --; | |||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | 4 | ▶ | if ($hi >= 0x01b21dd2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 4 | $hi -= 0x01b21dd2; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $hi += 0x0e4de22e; # wrap around | |||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 4 | $low /= 10000000.0; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 4 | $hi /= 78125.0 / 512 / 65536; # / 1000000 * 0x100000000 | |||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 4 | return $hi + $low; | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 5 | ▶ | sub is_v1 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v1: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 565 | 5 | ▶ | return $self->variant == 2 && $self->version == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->variant == 2 && $self->version == 1
MC/DC50%1/2
$self->variant == 2 && $self->version == 1
$self->variant == 2
$self->version == 1
Truth table66%2/3
A && B
A= $self->variant == 2B= $self->version == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | 5 | ▶ | sub is_v2 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v2: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 570 | 5 | ▶ | return $self->variant == 2 && $self->version == 2; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->variant == 2 && $self->version == 2
MC/DC50%1/2
$self->variant == 2 && $self->version == 2
$self->variant == 2
$self->version == 2
Truth table66%2/3
A && B
A= $self->variant == 2B= $self->version == 2
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 5 | ▶ | sub is_v3 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v3: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 5 | ▶ | return $self->variant == 2 && $self->version == 3; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->variant == 2 && $self->version == 3
MC/DC50%1/2
$self->variant == 2 && $self->version == 3
$self->variant == 2
$self->version == 3
Truth table66%2/3
A && B
A= $self->variant == 2B= $self->version == 3
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 5 | ▶ | sub is_v4 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v4: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 580 | 5 | ▶ | return $self->variant == 2 && $self->version == 4; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->variant == 2 && $self->version == 4
MC/DC50%1/2
$self->variant == 2 && $self->version == 4
$self->variant == 2
$self->version == 4
Truth table66%2/3
A && B
A= $self->variant == 2B= $self->version == 4
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 5 | ▶ | sub is_v5 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_v5: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 585 | 5 | ▶ | return $self->variant == 2 && $self->version == 5; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->variant == 2 && $self->version == 5
MC/DC50%1/2
$self->variant == 2 && $self->version == 5
$self->variant == 2
$self->version == 5
Truth table66%2/3
A && B
A= $self->variant == 2B= $self->version == 5
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | { | ||||||||||||||||||||||||||||||||||||||||||
| 589 | 10 | my %uuid_const; | |||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 10 | my %uuid_const_map = ( | |||||||||||||||||||||||||||||||||||||||||
| 592 | uuid_nil => '00000000-0000-0000-0000-000000000000', | ||||||||||||||||||||||||||||||||||||||||||
| 593 | uuid_ns_dns => '6ba7b810-9dad-11d1-80b4-00c04fd430c8', | ||||||||||||||||||||||||||||||||||||||||||
| 594 | uuid_ns_url => '6ba7b811-9dad-11d1-80b4-00c04fd430c8', | ||||||||||||||||||||||||||||||||||||||||||
| 595 | uuid_ns_oid => '6ba7b812-9dad-11d1-80b4-00c04fd430c8', | ||||||||||||||||||||||||||||||||||||||||||
| 596 | uuid_ns_x500 => '6ba7b814-9dad-11d1-80b4-00c04fd430c8', | ||||||||||||||||||||||||||||||||||||||||||
| 597 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 10 | ▶ | while (my ($id, $uuid) = each %uuid_const_map) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | my $sub | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 5 | ▶ | = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | 5 | ▶ | if (! defined $uuid_const{$id}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 5 | $uuid_const{$id} | |||||||||||||||||||||||||||||||||||||||||
| 604 | = __PACKAGE__->create_from_string($uuid); | ||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | 5 | return $uuid_const{$id}->clone(); | |||||||||||||||||||||||||||||||||||||||||
| 608 | 50 | }; | |||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 10 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 50 | *{__PACKAGE__ . '::' . $id} = $sub; | |||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 616 | __END__ | ||||||||||||||||||||||||||||||||||||||||||