blib/lib/CGI/Application/Plugin/DetectAjax.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 92.5% 25 / 27 CC 3 SCAR 7.9
CC
3
Cov
95%
is_ajax
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
↑ Summary
1 package CGI::Application::Plugin::DetectAjax;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use vars qw($VERSION @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 require Exporter;
7  
8 2 @CGI::Application::Plugin::DetectAjax::ISA = qw(Exporter);
9  
10 2 $VERSION = '0.06';
11  
12 2 @EXPORT = qw(
13 is_ajax
14 );
15  
16 3 ▶sub is_ajax {
Subroutine is_ajax: called CC=3 SCAR=11.0
Pod documented
17  
18 3 my $self = shift;
19  
20  
21 3 my $header = 'HTTP_X_REQUESTED_WITH';
22  
23 3 ▶ if (exists $ENV{$header} && lc $ENV{$header} eq 'xmlhttprequest') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{$header} and lc $ENV{$header} eq 'xmlhttprequest') { } 1 2 3
Condition66%2/3
exists $ENV{$header} and lc $ENV{$header} eq "xmlhttprequest"
!ll&&!rl&&r
201
MC/DC50%1/2
exists $ENV{$header} and lc $ENV{$header} eq "xmlhttprequest"
exists $ENV{$header} lc $ENV{$header} eq "xmlhttprequest"
Truth table66%2/3
A and B
A= exists $ENV{$header}B= lc $ENV{$header} eq "xmlhttprequest"
ABresult
0X0
100
111
24 1 return 1;
25 }
26 else {
27 2 return 0;
28 }
29  
30 }
31  
32  
33 2 1;
34  
35 __END__
↑ Summary