| 1 | 4 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Net::EGTS::SubRecord::Auth::DispatcherIdentity; | ||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | extends qw(Net::EGTS::SubRecord); | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use List::MoreUtils qw(natatime); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Encode qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Net::EGTS::Util qw(usize dumper_bitstring); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Net::EGTS::Codes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Dispatcher Type | ||||||||||||||||||||||||||||
| 15 | 4 | has DT => is => 'rw', isa => 'BYTE', default => 0; | |||||||||||||||||||||||||||
| 16 | # Dispatcher ID | ||||||||||||||||||||||||||||
| 17 | 4 | has DID => is => 'rw', isa => 'UINT'; | |||||||||||||||||||||||||||
| 18 | # Description | ||||||||||||||||||||||||||||
| 19 | has DSCR => | ||||||||||||||||||||||||||||
| 20 | is => 'rw', | ||||||||||||||||||||||||||||
| 21 | isa => 'Maybe[STRING]', | ||||||||||||||||||||||||||||
| 22 | trigger => sub { | ||||||||||||||||||||||||||||
| 23 | 5 | ▶ | my ($self, $value, $old) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 5 | ▶ | die 'Description too long' if defined($value) && length($value) > 255; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $value and length $value > 255
MC/DC0%0/2
defined $value and length $value > 255
defined $value
length $value > 255
Truth table66%2/3
A and B
A= defined $valueB= length $value > 255
| |||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | 4 | ; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | after 'decode' => sub { | ||||||||||||||||||||||||||||
| 30 | 3 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 31 | 3 | ▶ | die 'SubRecord not EGTS_SR_DISPATCHER_IDENTITY type' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | unless $self->SRT == EGTS_SR_DISPATCHER_IDENTITY; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 3 | my $bin = $self->SRD; | |||||||||||||||||||||||||||
| 35 | 3 | $self->DT( $self->nip(\$bin => 'C') ); | |||||||||||||||||||||||||||
| 36 | 3 | $self->DID( $self->nip(\$bin => 'L') ); | |||||||||||||||||||||||||||
| 37 | 3 | $self->DSCR( $self->nip(\$bin => 'a*' => length($bin)) ); | |||||||||||||||||||||||||||
| 38 | 4 | }; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | before 'encode' => sub { | ||||||||||||||||||||||||||||
| 41 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 42 | 2 | ▶ | die 'SubRecord not EGTS_SR_DISPATCHER_IDENTITY type' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | unless $self->SRT == EGTS_SR_DISPATCHER_IDENTITY; | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 2 | my $bin = pack 'C L' => $self->DT, $self->DID; | |||||||||||||||||||||||||||
| 46 | 2 | ▶ | $bin .= pack 'a*' => $self->DSCR if defined $self->DSCR; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 2 | $self->SRD( $bin ); | |||||||||||||||||||||||||||
| 49 | 4 | }; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | around BUILDARGS => sub { | ||||||||||||||||||||||||||||
| 52 | 5 | ▶ | my $orig = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 53 | 5 | my $class = shift; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # simple scalar decoding support | ||||||||||||||||||||||||||||
| 56 | 5 | ▶ | my $bin = @_ % 2 ? shift : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 5 | my %opts = @_; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # Description is CP-1251 | ||||||||||||||||||||||||||||
| 60 | 5 | ▶ | $opts{DSCR} = Encode::encode('CP1251', $opts{DSCR}) if defined $opts{DSCR}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 5 | ▶ | return $class->$orig( bin => $bin, %opts, SRT => EGTS_SR_DISPATCHER_IDENTITY) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | if $bin; | ||||||||||||||||||||||||||||
| 64 | 4 | return $class->$orig( %opts, SRT => EGTS_SR_DISPATCHER_IDENTITY); | |||||||||||||||||||||||||||
| 65 | 4 | }; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | augment as_debug => sub { | ||||||||||||||||||||||||||||
| 68 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 69 | 4 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 4 | my @bytes = ((unpack('B*', $self->SRD)) =~ m{.{8}}g); | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 4 | my @str; | |||||||||||||||||||||||||||
| 74 | 4 | push @str => sprintf('DT: %s', splice @bytes, 0 => usize('C')); | |||||||||||||||||||||||||||
| 75 | 4 | push @str => sprintf('DID: %s %s %s %s', splice @bytes, 0 => usize('L')); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 4 | my $it = natatime 4, @bytes; | |||||||||||||||||||||||||||
| 78 | 4 | my @chunks; | |||||||||||||||||||||||||||
| 79 | 4 | ▶ | while (my @vals = $it->()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 3 | push @chunks, join(' ', @vals); | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 4 | push @str => sprintf('DSCR: %s', join("\n ", @chunks)); | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 4 | return @str; | |||||||||||||||||||||||||||
| 85 | 4 | }; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 4 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||