Jumptable.pm

filter: Statementstmt 46.6% 14 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 2 / 2 totaltotal 44.4% 20 / 45 CC 5 SCAR 21.9
CC
5
Cov
39%
jump
20.0
_init
6.0
jumptable
2.0
CRAP 8.9
« Common.pm ↑ Summary AddressCodes.pm »
1 # BW::Jumptable.pm
2 # Jump table support for BW::*
3 #
4 # by Bill Weinman - http://bw.org/
5 # Copyright (c) 1995-2010 The BearHeart Group, LLC
6 #
7 # See POD for History
8  
9 package BW::Jumptable;
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use base qw( BW::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use BW::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 our $VERSION = "1.3.1";
17  
18 sub _init
19 0 ▶{
Subroutine _init: not called CC=2 SCAR=17.9
20 0 my $self = shift;
21 0 $self->SUPER::_init(@_);
22  
23 0 ▶ return FAILURE unless $self->{jumptable};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"jumptable"} 0 0 0
24  
25 0 return SUCCESS;
26 }
27  
28 # _setter_getter entry points
29 0 ▶sub jumptable { BW::Base::_setter_getter(@_); }
Subroutine jumptable: not called CC=1 SCAR=6.9
Pod documented
30  
31 sub jump
32 0 ▶{
Subroutine jump: not called CC=4 SCAR=30.0
Pod documented
33 0 my $sn = 'jump';
34 0 my $self = shift;
35 0 my $action = shift;
36  
37 0 ▶ return $self->_error("$sn: no action") unless $action;
Branch: 1 branch
BranchTrueFalseTotal
unless $action 0 0 0
38  
39 0 foreach my $j ( keys %{ $self->{jumptable} } ) {
40 0 ▶ if ( $j eq $action ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j eq $action) 0 0 0
41 0 &{ $self->{jumptable}{$j} }();
42 0 return SUCCESS;
43 }
44 }
45  
46 0 return $self->_error("$sn: action not found ($action)");
47 }
48  
49 1 1;
50  
51 __END__
« Common.pm ↑ Summary AddressCodes.pm »