blib/lib/Algorithm/CheckDigits/M07_001.pm

filter: Statementstmt 33.3% 14 / 42 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 4 / 10 Podpod 80.0% 4 / 5 totaltotal 28.9% 22 / 76 CC 10 SCAR 20.5
CC
10
Cov
24%
basenumber
12.0
checkdigit
12.0
_compute_checkdigit
12.0
CRAP 7.8
« blib/lib/Algorithm/CheckDigits/MXX_001.pm ↑ Summary blib/lib/Algorithm/CheckDigits/M10_001.pm »
1 package Algorithm::CheckDigits::M07_001;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use version; our $VERSION = 'v1.3.6';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our @ISA = qw(Algorithm::CheckDigits);
10  
11 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
12 0 my $proto = shift;
13 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
14 0 return bless({}, $class);
15 } # new()
16  
17 0 ▶sub is_valid {
Subroutine is_valid: not called CC=2 SCAR=17.9
Pod documented
18 0 my ($self,$number) = @_;
19 0 ▶ if ($number =~ /^([0-9]*)([0-9])$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($number =~ /^([0-9]*)([0-9])$/) 0 0 0
20 0 return ($2 == _compute_checkdigit($1));
21 }
22 0 return 0;
23 } # is_valid()
24  
25 0 ▶sub complete {
Subroutine complete: not called CC=2 SCAR=17.9
Pod documented
26 0 my ($self,$number) = @_;
27 0 ▶ if ($number =~ /^([0-9]*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($number =~ /^([0-9]*)$/) 0 0 0
28 0 return $number . _compute_checkdigit($1);
29 }
30 0 return undef;
31 } # complete()
32  
33 0 ▶sub basenumber {
Subroutine basenumber: not called CC=3 SCAR=24.8
Pod documented
34 0 my ($self,$number) = @_;
35 0 ▶ if ($number =~ /^([0-9]*)([0-9])$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($number =~ /^([0-9]*)([0-9])$/) 0 0 0
36 0 ▶ return $1 if ($2 == _compute_checkdigit($1));
Branch: 1 branch
BranchTrueFalseTotal
if $2 == _compute_checkdigit($1) 0 0 0
37 }
38 0 return undef;
39 } # basenumber()
40  
41 0 ▶sub checkdigit {
Subroutine checkdigit: not called CC=3 SCAR=24.8
Pod documented
42 0 my ($self,$number) = @_;
43 0 ▶ if ($number =~ /^([0-9]*)([0-9])$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($number =~ /^([0-9]*)([0-9])$/) 0 0 0
44 0 ▶ return $2 if ($2 == _compute_checkdigit($1));
Branch: 1 branch
BranchTrueFalseTotal
if $2 == _compute_checkdigit($1) 0 0 0
45 }
46 0 return undef;
47 } # checkdigit()
48  
49 0 ▶sub _compute_checkdigit {
Subroutine _compute_checkdigit: not called CC=3 SCAR=24.8
50 0 my $number = shift;
51 0 my @digits = split(//,$number);
52 0 my $even = 0;
53 0 my $sum = 0;
54 0 foreach my $digit (@digits) {
55 0 $sum += $digit;
56 0 ▶ $sum += $digit if ($even);
Branch: 1 branch
BranchTrueFalseTotal
if $even 0 0 0
57 0 $even = not $even;
58 }
59 0 return $sum % 7;
60 } # _compute_checkdigit()
61  
62 # Preloaded methods go here.
63  
64 1 1;
65 __END__
« blib/lib/Algorithm/CheckDigits/MXX_001.pm ↑ Summary blib/lib/Algorithm/CheckDigits/M10_001.pm »