Petitcom/Resource/GRP.pm

filter: Statementstmt 100% 52 / 52 Branchbran 100% 12 / 12 Conditioncond 50.0% 7 / 14 MC/DCmcdc 12.5% 1 / 8 Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 3 totaltotal 83.3% 85 / 102 CC 13 SCAR 12.8
CC
13
Cov
91%
save
6.4
load
5.0
data
4.0
CRAP 3.6
« Petitcom/QRCode.pm ↑ Summary Petitcom/Resource.pm »
1 package Data::Petitcom::Resource::GRP;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use parent qw{ Data::Petitcom::Resource };
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use bytes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Data::Petitcom::PTC;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Data::Petitcom::BMP qw{ Load BMP2DATA DATA2BMP };
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶use constant RESOURCE => 'GRP';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use constant BMP_WIDTH => 256;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use constant BMP_HEIGHT => 192;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use constant PTC_NAME => 'DPTC_GRP';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 23 ▶sub data {
Subroutine data: called CC=4 SCAR=13.9
Pod undocumented
18 23 my $self = shift;
19 23 ▶ if (my $raw_bmp = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $raw_bmp = shift()) 10 13 23
20 10 my $bmp = Load($raw_bmp);
21 Carp::croak "unsupported width x height: $bmp->{width} x $bmp->{height}"
22 if ( $bmp->{width} != $self->BMP_WIDTH()
23 10 ▶ || $bmp->{height} != $self->BMP_HEIGHT() );
Branch: 1 branch
BranchTrueFalseTotal
if $bmp->{"width"} != $self->BMP_WIDTH or $bmp->{"height"} != $self->BMP_HEIGHT 2 8 10
Condition66%2/3
$bmp->{"width"} != $self->BMP_WIDTH or $bmp->{"height"} != $self->BMP_HEIGHT
l!l&&r!l&&!r
028
MC/DC50%1/2
$bmp->{"width"} != $self->BMP_WIDTH or $bmp->{"height"} != $self->BMP_HEIGHT
$bmp->{"width"} != $self->BMP_WIDTH $bmp->{"height"} != $self->BMP_HEIGHT
Truth table66%2/3
A or B
A= $bmp->{"width"} != $self->BMP_WIDTHB= $bmp->{"height"} != $self->BMP_HEIGHT
ABresult
1X1
011
000
24 8 $self->{data} = $raw_bmp;
25 }
26 21 return $self->{data};
27 }
28  
29 4 ▶sub save {
Subroutine save: called CC=6 SCAR=18.6
Pod undocumented
30 4 my $self = shift;
31  
32 4 my %opts = @_;
33 4 ▶ my $name = delete $opts{name} || $self->PTC_NAME();
Condition33%1/3
delete $opts{'name'} || $self->PTC_NAME
l!l&&r!l&&!r
040
MC/DC0%0/2
delete $opts{'name'} || $self->PTC_NAME
delete $opts{'name'} $self->PTC_NAME
Truth table33%1/3
A || B
A= delete $opts{'name'}B= $self->PTC_NAME
ABresult
1X1
011
000
34 my $sp_width = ( $self->RESOURCE() eq 'GRP' )
35 ? 64
36 4 ▶ : delete $opts{sp_width} || 16;
Branch: 1 branch
BranchTrueFalseTotal
$self->RESOURCE eq 'GRP' ? : 2 2 4
Condition50%1/2
delete $opts{"sp_width"} or 16
l!l
20
MC/DC0%0/1
delete $opts{"sp_width"} or 16
delete $opts{"sp_width"}
Truth table50%1/2
A
A= delete $opts{"sp_width"}
Aresult
11
00
37 my $sp_height = ( $self->RESOURCE() eq 'GRP' )
38 ? 64
39 4 ▶ : delete $opts{sp_height} || 16;
Branch: 1 branch
BranchTrueFalseTotal
$self->RESOURCE eq 'GRP' ? : 2 2 4
Condition50%1/2
delete $opts{"sp_height"} or 16
l!l
20
MC/DC0%0/1
delete $opts{"sp_height"} or 16
delete $opts{"sp_height"}
Truth table50%1/2
A
A= delete $opts{"sp_height"}
Aresult
11
00
40  
41  
42 4 my $ptc = Data::Petitcom::PTC->new(
43 resource => $self->RESOURCE(),
44 name => $name,
45 version => 'PETC0100',
46 data => BMP2DATA(
47 $self->data,
48 sp_width => $sp_width,
49 sp_height => $sp_height,
50 ),
51 );
52 4 return $ptc;
53 }
54  
55 2 ▶sub load {
Subroutine load: called CC=5 SCAR=16.2
Pod undocumented
56 2 my $self = shift;
57 2 my $ptc = shift;
58  
59 2 my %opts = @_;
60 my $sp_width = ( $self->RESOURCE() eq 'GRP' )
61 ? 64
62 2 ▶ : delete $opts{sp_width} || 16;
Branch: 1 branch
BranchTrueFalseTotal
$self->RESOURCE eq 'GRP' ? : 1 1 2
Condition50%1/2
delete $opts{"sp_width"} or 16
l!l
10
MC/DC0%0/1
delete $opts{"sp_width"} or 16
delete $opts{"sp_width"}
Truth table50%1/2
A
A= delete $opts{"sp_width"}
Aresult
11
00
63 my $sp_height = ( $self->RESOURCE() eq 'GRP' )
64 ? 64
65 2 ▶ : delete $opts{sp_height} || 16;
Branch: 1 branch
BranchTrueFalseTotal
$self->RESOURCE eq 'GRP' ? : 1 1 2
Condition50%1/2
delete $opts{"sp_height"} or 16
l!l
10
MC/DC0%0/1
delete $opts{"sp_height"} or 16
delete $opts{"sp_height"}
Truth table50%1/2
A
A= delete $opts{"sp_height"}
Aresult
11
00
66  
67 2 my $bmp = DATA2BMP(
68 bytes::substr( $ptc->data, 0x0C ),
69 width => $self->BMP_WIDTH(),
70 height => $self->BMP_HEIGHT(),
71 sp_width => $sp_width,
72 sp_height => $sp_height,
73 );
74 2 $self->data($bmp);
75 2 return $self;
76 }
77  
78 4 1;
« Petitcom/QRCode.pm ↑ Summary Petitcom/Resource.pm »