Proxy/HeaderFilter/simple.pm

filter: Statementstmt 72.2% 26 / 36 Branchbran 50.0% 7 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 100% 5 / 5 totaltotal 69.2% 45 / 65 CC 8 SCAR 20.0
CC
8
Cov
66%
init
15.8
__ANON__
2.0
begin
2.0
CRAP 7.4
« Proxy/HeaderFilter/standard.pm ↑ Summary Proxy/BodyFilter/htmltext.pm »
1 package HTTP::Proxy::HeaderFilter::simple;
2 15 $HTTP::Proxy::HeaderFilter::simple::VERSION = '0.304';
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use HTTP::Proxy::HeaderFilter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use vars qw( @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 @ISA = qw( HTTP::Proxy::HeaderFilter );
8  
9 15 my $methods = join '|', qw( begin filter end );
10 15 $methods = qr/^(?:$methods)$/;
11  
12 9 ▶sub init {
Subroutine init: called CC=7 SCAR=27.6
Pod documented
13 9 my $self = shift;
14  
15 9 ▶ croak "Constructor called without argument" unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 8 9
16 8 ▶ if ( @_ == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 8 0 8
17 8 ▶ croak "Single parameter must be a CODE reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] eq "CODE" 1 7 8
18 unless ref $_[0] eq 'CODE';
19 7 $self->{_filter} = $_[0];
20 }
21 else {
22 0 ▶ $self->{_filter} = sub { }; # default
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
24 0 my ( $name, $code ) = splice @_, 0, 2;
25  
26 # basic error checking
27 0 ▶ croak "Parameter to $name must be a CODE reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $code eq "CODE" 0 0 0
28 unless ref $code eq 'CODE';
29 0 ▶ croak "Unkown method $name" unless $name =~ $methods;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /$methods/ 0 0 0
30  
31 0 $self->{"_$name"} = $code;
32 }
33 }
34 }
35  
36 # transparently call the actual methods
37 0 ▶sub begin { goto &{ $_[0]{_begin} }; }
Subroutine begin: not called CC=1 SCAR=6.9
Pod documented
38 4 ▶sub filter { goto &{ $_[0]{_filter} }; }
Subroutine filter: called CC=1 SCAR=0.0
Pod documented
39 0 ▶sub end { goto &{ $_[0]{_end} }; }
Subroutine end: not called CC=1 SCAR=6.9
Pod documented
40  
41 15 ▶sub can {
Subroutine can: called CC=2 SCAR=6.9
Pod documented
42 15 my ( $self, $method ) = @_;
43 return $method =~ $methods
44 15 ▶ ? $self->{"_$method"}
Branch: 1 branch
BranchTrueFalseTotal
$method =~ /$methods/ ? : 3 12 15
45 : UNIVERSAL::can( $self, $method );
46 }
47  
48 15 1;
49  
50 __END__
« Proxy/HeaderFilter/standard.pm ↑ Summary Proxy/BodyFilter/htmltext.pm »