Any/Fake.pm

filter: Statementstmt 92.6% 38 / 41 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 84.6% 11 / 13 Podpod 0.0% 0 / 3 totaltotal 76.4% 52 / 68 CC 4 SCAR 9.3
CC
4
Cov
84%
__ANON__
6.6
call_cb
2.0
call_p
2.0
CRAP 2.5
« Any/Wrapper.pm ↑ Summary Any/Fake/Request.pm »
1 package UserAgent::Any::Fake;
2  
3 1 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use UserAgent::Any::Fake::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use UserAgent::Any::Fake::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use UserAgent::Any::Impl::Helper 'generate_methods';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 our $VERSION = 0.01;
15  
16 1 extends 'UserAgent::Any';
17 1 with 'UserAgent::Any::Impl';
18  
19 1 has '+_impl' => (required => 0,);
20 1 has '+ua' => (required => 0,);
21  
22 1 has _handler => (is => 'ro',);
23  
24 2 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=4 SCAR=18.9
25 2 my ($orig, $class, @args) = @_;
26  
27 2 ▶ return {_handler => $args[0]}
Branch: 1 branch
BranchTrueFalseTotal
if @args == 1 and ref $args[0] ne "HASH" || !builtin::blessed($args[0]) 2 0 2
Condition33%2/6
@args == 1 and ref $args[0] ne "HASH" || !builtin::blessed($args[0])
!ll&&!rl&&r
002
ref $args[0] ne "HASH" or not builtin::blessed($args[0])
l!l&&r!l&&!r
200
MC/DC0%0/3
@args == 1 and ref $args[0] ne "HASH" || !builtin::blessed($args[0])
@args == 1 ref $args[0] ne "HASH" not builtin::blessed($args[0])
Truth table25%1/4
A and B or not(C)
A= @args == 1B= ref $args[0] ne "HASH"C= not builtin::blessed($args[0])
ABCresult
0XX0
1000
11X1
1011
28 if @args == 1 && (ref($args[0]) ne 'HASH' || !blessed($args[0]));
29  
30 0 return $class->$orig(@args);
31 1 };
32  
33 2 ▶sub call ($self, @args) {
Subroutine call: called CC=1 SCAR=0.0
Pod undocumented
34 2 my $req = UserAgent::Any::Fake::Request->new(@args);
35 2 my $res = UserAgent::Any::Fake::Response->new(status_code => 200, status_text => 'SUCCESS');
36 2 $self->_handler->($req, $res);
37 2 return $res;
38 }
39  
40 0 ▶sub call_cb ($self, $url, %params) {
Subroutine call_cb: not called CC=1 SCAR=6.9
Pod undocumented
41 0 croak 'UserAgent::Any async methods are not implemented with UserAgent::Any::Fake';
42 }
43  
44 0 ▶sub call_p ($self, $url, %params) {
Subroutine call_p: not called CC=1 SCAR=6.9
Pod undocumented
45 0 croak 'UserAgent::Any async methods are not implemented with UserAgent::Any::Fake';
46 }
47  
48 1 ▶BEGIN { generate_methods() }
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 1 1;
51  
52 __END__
« Any/Wrapper.pm ↑ Summary Any/Fake/Request.pm »