| 1 | package Algorithm::CheckDigits::M11_008; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use version; our $VERSION = 'v1.3.6'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | our @ISA = qw(Algorithm::CheckDigits); | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | my @weight = ( 2, 7, 6, 5, 4, 3, 2, 1 ); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 1 | my $proto = shift; | |||||||||||||||||||||||||||
| 16 | 1 | my $type = shift; | |||||||||||||||||||||||||||
| 17 | 1 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 18 | 1 | my $self = bless({}, $class); | |||||||||||||||||||||||||||
| 19 | 1 | $self->{type} = lc($type); | |||||||||||||||||||||||||||
| 20 | 1 | return $self; | |||||||||||||||||||||||||||
| 21 | } # new() | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | sub is_valid { | ||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 2 | my ($self,$number) = @_; | |||||||||||||||||||||||||||
| 25 | 2 | ▶ | if ($number =~ /^(\d{8})$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 2 | return 0 == $self->_compute_checkdigits($1); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 0 | return '' | |||||||||||||||||||||||||||
| 29 | } # is_valid() | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | sub complete { | ||||||||||||||||||||||||||
|
Subroutine
complete: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 1 | my ($self,$number) = @_; | |||||||||||||||||||||||||||
| 33 | 1 | ▶ | return "$1" if( $number =~ /^(\d{8})$/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$number =~ /^(\d{8})$/ and 0 == $self->_compute_checkdigits($1)
MC/DC0%0/2
$number =~ /^(\d{8})$/ and 0 == $self->_compute_checkdigits($1)
$number =~ /^(\d{8})$/
0 == $self->_compute_checkdigits($1)
Truth table33%1/3
A and B
A= $number =~ /^(\d{8})$/B= 0 == $self->_compute_checkdigits($1)
| |||||||||||||||||||||||||||||
| 34 | and 0 == $self->_compute_checkdigits($1)); | ||||||||||||||||||||||||||||
| 35 | 0 | return ''; | |||||||||||||||||||||||||||
| 36 | } # complete() | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | sub basenumber { | ||||||||||||||||||||||||||
|
Subroutine
basenumber: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 1 | my ($self,$number) = @_; | |||||||||||||||||||||||||||
| 40 | 1 | ▶ | return "$1" if( $number =~ /^(\d{8})$/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$number =~ /^(\d{8})$/ and 0 == $self->_compute_checkdigits($1)
MC/DC0%0/2
$number =~ /^(\d{8})$/ and 0 == $self->_compute_checkdigits($1)
$number =~ /^(\d{8})$/
0 == $self->_compute_checkdigits($1)
Truth table33%1/3
A and B
A= $number =~ /^(\d{8})$/B= 0 == $self->_compute_checkdigits($1)
| |||||||||||||||||||||||||||||
| 41 | and 0 == $self->_compute_checkdigits($1)); | ||||||||||||||||||||||||||||
| 42 | 0 | return ''; | |||||||||||||||||||||||||||
| 43 | } # basenumber() | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 1 | ▶ | sub checkdigit { | ||||||||||||||||||||||||||
|
Subroutine
checkdigit: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 1 | my ($self,$number) = @_; | |||||||||||||||||||||||||||
| 47 | 1 | ▶ | return '' if( $number =~ /^(\d{8})$/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$number =~ /^(\d{8})$/ and 0 == $self->_compute_checkdigits($1)
MC/DC0%0/2
$number =~ /^(\d{8})$/ and 0 == $self->_compute_checkdigits($1)
$number =~ /^(\d{8})$/
0 == $self->_compute_checkdigits($1)
Truth table33%1/3
A and B
A= $number =~ /^(\d{8})$/B= 0 == $self->_compute_checkdigits($1)
| |||||||||||||||||||||||||||||
| 48 | and 0 == $self->_compute_checkdigits($1)); | ||||||||||||||||||||||||||||
| 49 | 0 | return undef; | |||||||||||||||||||||||||||
| 50 | } # checkdigit() | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 5 | ▶ | sub _compute_checkdigits { | ||||||||||||||||||||||||||
|
Subroutine
_compute_checkdigits: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 53 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 5 | my @digits = split(//,shift); | |||||||||||||||||||||||||||
| 56 | 5 | my $sum = 0; | |||||||||||||||||||||||||||
| 57 | 5 | ▶ | for (my $i = 0; $i <= $#digits; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 40 | $sum += $weight[$i] * $digits[$i]; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 5 | $sum %= 11; | |||||||||||||||||||||||||||
| 61 | 5 | return $sum; | |||||||||||||||||||||||||||
| 62 | } # _compute_checkdigit() | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # Preloaded methods go here. | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 2 | 1; | |||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||