Any.pm

filter: Statementstmt 76.4% 26 / 34 Branchbran 57.1% 8 / 14 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 67.1% 43 / 64 CC 10 SCAR 20.4
CC
10
Cov
67%
__ANON__
13.1
__ANON__
6.6
BEGIN
1.0
CRAP 7.7
« Any/Response.pm ↑ Summary Any/Impl/Helper.pm »
1 package UserAgent::Any;
2  
3 7 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 7 our $VERSION = 0.05;
12  
13 7 our @CARP_NOT = 'UserAgent::Any::Wrapper';
14  
15 # We expect a single argument to this class, so we take it without the need to
16 # pass it in a hash. See:
17 # https://metacpan.org/pod/Moo#BUILDARGS
18 3 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=4 SCAR=18.9
19 3 my ($orig, $class, @args) = @_;
20  
21 3 ▶ return {ua => $args[0]}
Branch: 1 branch
BranchTrueFalseTotal
if @args == 1 and ref $args[0] ne "HASH" || !builtin::blessed($args[0]) 3 0 3
Condition33%2/6
@args == 1 and ref $args[0] ne "HASH" || !builtin::blessed($args[0])
!ll&&!rl&&r
003
ref $args[0] ne "HASH" or not builtin::blessed($args[0])
l!l&&r!l&&!r
300
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
22 if @args == 1 && (ref($args[0]) ne 'HASH' || !blessed($args[0]));
23  
24 0 return $class->$orig(@args);
25 7 };
26  
27 has _impl => (
28 init_arg => 'ua',
29 is => 'ro',
30 required => 1,
31 handles => 'UserAgent::Any::Impl',
32 3 ▶ coerce => sub ($ua) {
Subroutine __ANON__: called CC=7 SCAR=25.7
33 3 ▶ croak 'Passed User Agent object must be a blessed reference' unless blessed($ua);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($ua) 0 3 3
34 3 ▶ if ($ua isa LWP::UserAgent) {
Branch: 5 branches
BranchTrueFalseTotal
if ($ua isa 'LWP::UserAgent') { } 2 1 3
elsif ($ua isa 'AnyEvent::UserAgent') { } 0 1 1
elsif ($ua isa 'Mojo::UserAgent') { } 0 1 1
elsif ($ua isa 'HTTP::Promise') { } 0 1 1
elsif ($ua->DOES('UserAgent::Any')) { } 1 0 1
35 2 require UserAgent::Any::Impl::LwpUserAgent;
36 2 return UserAgent::Any::Impl::LwpUserAgent->new(ua => $ua);
37 } elsif ($ua isa AnyEvent::UserAgent) {
38 0 require UserAgent::Any::Impl::AnyEventUserAgent;
39 0 return UserAgent::Any::Impl::AnyEventUserAgent->new(ua => $ua);
40 } elsif ($ua isa Mojo::UserAgent) {
41 0 require UserAgent::Any::Impl::MojoUserAgent;
42 0 return UserAgent::Any::Impl::MojoUserAgent->new(ua => $ua);
43 } elsif ($ua isa HTTP::Promise) {
44 0 require UserAgent::Any::Impl::HttpPromise;
45 0 return UserAgent::Any::Impl::HttpPromise->new(ua => $ua);
46 } elsif ($ua->DOES('UserAgent::Any')) {
47 1 return $ua;
48 } else {
49 0 croak 'Unknown User Agent type "'.ref($ua).'"';
50 }
51 }
52 7 );
53  
54 7 1;
55  
56 __END__
« Any/Response.pm ↑ Summary Any/Impl/Helper.pm »