Any/Fake/Request.pm

filter: Statementstmt 93.7% 30 / 32 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 85.7% 42 / 49 CC 6 SCAR 9.1
CC
6
Cov
88%
header
4.5
__ANON__
2.0
headers
2.0
CRAP 2.5
« Any/Fake.pm ↑ Summary Any/Impl/LwpUserAgent.pm »
1 package UserAgent::Any::Fake::Request;
2  
3 1 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use UserAgent::Any::Impl::Helper 'params_to_hash';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = 0.01;
11  
12 1 has [qw(url method _headers content)] => (is => 'ro',);
13  
14 2 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
15 2 my ($orig, $class, $method, $url, @args) = @_;
16  
17 2 my $content;
18 2 ▶ $content = pop @args if @args % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @args % 2 0 2 2
19  
20 return {
21 2 url => $url,
22 method => $method,
23 _headers => params_to_hash(@args),
24 content => $content
25 };
26 1 };
27  
28 2 ▶sub header ($self, $k) {
Subroutine header: called CC=4 SCAR=15.0
Pod undocumented
29 2 my $v = $self->_headers->{$k};
30 2 ▶ return unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 2 2
31 2 ▶ return $v unless ref($v);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $v 1 1 2
32 1 ▶ return @{$v} if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 1 0 1
33 0 return join(',', @{$v});
34 }
35  
36 1 ▶sub headers ($self) {
Subroutine headers: called CC=2 SCAR=6.9
Pod undocumented
37 1 my @all_headers;
38 1 for my $k (sort keys %{$self->_headers}) {
39 2 push @all_headers, map { ($k, $_) } $self->header($k);
40 }
41 1 return @all_headers;
42 }
43  
44 1 1;
45  
46 __END__
« Any/Fake.pm ↑ Summary Any/Impl/LwpUserAgent.pm »