Parametry/ParamerHelpers.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 85.7% 12 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 2 totaltotal 88.8% 48 / 54 CC 8 SCAR 11.9
CC
8
Cov
93%
matching
6.0
__ANON__
3.0
__ANON__
1.1
CRAP 3.3
↑ Summary Parametry.pm »
1 package Mojolicious::Plugin::Parametry::ParamerHelpers;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Mojo::Collection;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '1.001002'; # VERSION
8  
9 16 ▶sub new { bless { _c => $_[1] }, $_[0] }
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10  
11 16 ▶sub matching {
Subroutine matching: called CC=6 SCAR=18.0
Pod undocumented
12 16 my ($self, $re, %args) = @_;
13 16 my $c = $self->{_c};
14  
15 16 ▶ $re = qr/^\Q$re\E/ unless ref $re eq 'Regexp';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $re eq "Regexp" 9 7 16
16 16 my $params = Mojo::Collection->new(grep /$re/, $c->req->params->names->@*);
17  
18  
19 16 ▶ if ($args{as_hash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"as_hash"}) 4 12 16
20 8 ▶ return +{ $params->map(sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
21 8 my $orig_name = $_;
22 8 ▶ $args{subst} and s/$re/$args{subst}/;
Branch: 1 branch
BranchTrueFalseTotal
$args{"subst"} and s/$re/$args{"subst"}/ 0 8 8
23 8 ▶ $args{strip} and s/$re//;
Branch: 1 branch
BranchTrueFalseTotal
$args{"strip"} and s/$re// 4 4 8
24 8 $_ => $c->param($orig_name)
25 4 })->each }
26 }
27  
28 $args{vals}
29 12 ▶ and return $params->map(sub {$c->param($_)});
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$args{"vals"} and return $params->map(sub { $c->param($_); } ) 4 8 12
30  
31 0 ▶ $args{subst} and $params = $params->map(sub {s/$re/$args{subst}/r});
Subroutine __ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
$args{"subst"} and $params = $params->map(sub { s/$re/$args{"subst"}/r; } ) 0 8 8
32 8 ▶ $args{strip} and $params = $params->map(sub {s/$re//r});
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$args{"strip"} and $params = $params->map(sub { s/$re//r; } ) 2 6 8
33 8 $params
34 }
35  
36 3 1;
37  
38 __END__
↑ Summary Parametry.pm »