Proxy/BodyFilter/simple.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 14 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 6 / 6 totaltotal 100% 74 / 74 CC 9 SCAR 14.0
CC
9
Cov
100%
init
8.0
can
2.0
BEGIN
1.0
CRAP 4.1
« Proxy/BodyFilter/lines.pm ↑ Summary Proxy/FilterStack.pm »
1 package HTTP::Proxy::BodyFilter::simple;
2 7 $HTTP::Proxy::BodyFilter::simple::VERSION = '0.304';
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use HTTP::Proxy::BodyFilter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use vars qw( @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 @ISA = qw( HTTP::Proxy::BodyFilter );
8  
9 7 my $methods = join '|', qw( begin filter end will_modify );
10 7 $methods = qr/^(?:$methods)$/;
11  
12 17 ▶sub init {
Subroutine init: called CC=8 SCAR=20.8
Pod documented
13 17 my $self = shift;
14  
15 17 ▶ croak "Constructor called without argument" unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 16 17
16  
17 16 $self->{_will_modify} = 1;
18  
19 16 ▶ if ( @_ == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 7 9 16
20 7 ▶ croak "Single parameter must be a CODE reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] eq "CODE" 1 6 7
21 unless ref $_[0] eq 'CODE';
22 6 $self->{_filter} = $_[0];
23 }
24 else {
25 9 ▶ $self->{_filter} = sub { }; # default
Subroutine __ANON__: called CC=1 SCAR=0.0
26 9 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 14 7 21
27 14 my ( $name, $code ) = splice @_, 0, 2;
28  
29 # basic error checking
30 14 ▶ croak "Parameter to $name must be a CODE reference"
Branch: 1 branch
BranchTrueFalseTotal
if $name ne "will_modify" and ref $code ne "CODE" 1 13 14
Condition100%3/3
$name ne "will_modify" and ref $code ne "CODE"
!ll&&!rl&&r
1121
MC/DC100%2/2
$name ne "will_modify" and ref $code ne "CODE"
$name ne "will_modify" ref $code ne "CODE"
Truth table100%3/3
A and B
A= $name ne "will_modify"B= ref $code ne "CODE"
ABresult
0X0
100
111
31 if $name ne 'will_modify' && ref $code ne 'CODE';
32 13 ▶ croak "Unkown method $name"
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /$methods/ 1 12 13
33 unless $name =~ $methods;
34  
35 12 $self->{"_$name"} = $code;
36 }
37 }
38 }
39  
40 # transparently call the actual methods
41 1 ▶sub begin { goto &{ $_[0]{_begin} }; }
Subroutine begin: called CC=1 SCAR=0.0
Pod documented
42 14 ▶sub filter { goto &{ $_[0]{_filter} }; }
Subroutine filter: called CC=1 SCAR=0.0
Pod documented
43 1 ▶sub end { goto &{ $_[0]{_end} }; }
Subroutine end: called CC=1 SCAR=0.0
Pod documented
44  
45 7 ▶sub will_modify { return $_[0]{_will_modify} }
Subroutine will_modify: called CC=1 SCAR=0.0
Pod documented
46  
47 31 ▶sub can {
Subroutine can: called CC=2 SCAR=6.9
Pod documented
48 31 my ( $self, $method ) = @_;
49 return $method =~ $methods
50 31 ▶ ? $self->{"_$method"}
Branch: 1 branch
BranchTrueFalseTotal
$method =~ /$methods/ ? : 10 21 31
51 : UNIVERSAL::can( $self, $method );
52 }
53  
54 7 1;
55  
56 __END__
« Proxy/BodyFilter/lines.pm ↑ Summary Proxy/FilterStack.pm »