blib/lib/Dispatcher/Small.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 6 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 94.7% 36 / 38 CC 5 SCAR 11.7
CC
5
Cov
97%
match
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
↑ Summary
1 package Dispatcher::Small;
2 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = "0.02";
7  
8 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
9 1 my $class = shift;
10 1 return bless +{ @_ }, $class;
11 }
12  
13 10 ▶sub match {
Subroutine match: called CC=5 SCAR=16.1
Pod documented
14 10 my ($self, $env) = @_;
15 10 my $i = 0;
16 10 my ($regex, $class, @capture);
17 10 ▶ my $path = $env->{PATH_INFO} || '/';
Condition50%1/2
$env->{'PATH_INFO'} || '/'
l!l
100
MC/DC0%0/1
$env->{'PATH_INFO'} || '/'
$env->{'PATH_INFO'}
Truth table50%1/2
A
A= $env->{'PATH_INFO'}
Aresult
11
00
18 10 my $method = $env->{REQUEST_METHOD};
19 10 ▶ while ($regex = $self->{$method}[$i * 2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($regex = $self->{$method}[$i * 2]) 30 2 32
20 30 ▶ if (@capture = $path =~ $regex) {
Branch: 1 branch
BranchTrueFalseTotal
if (@capture = $path =~ /$regex/) 8 22 30
21 return +{
22 8 ▶ %{ $self->{$method}[$i * 2 + 1] },
Branch: 1 branch
BranchTrueFalseTotal
%+ ? : 2 6 8
23 %+ ? %+ : ( capture => [@capture] ),
24 };
25 }
26 22 $i++;
27 }
28 }
29  
30 2 1;
31 __END__
↑ Summary