| 1 | package UserAgent::Any::Response; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use 5.036; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | our $VERSION = 0.01; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | my ($orig, $class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | return {res => $args[0]} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@args == 1 and ref $args[0] ne "HASH" || !builtin::blessed($args[0])
ref $args[0] ne "HASH" or not builtin::blessed($args[0])
MC/DC33%1/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 table50%2/4
A and B or not(C)
A= @args == 1B= ref $args[0] ne "HASH"C= not builtin::blessed($args[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | if @args == 1 && (ref($args[0]) ne 'HASH' || !blessed($args[0])); | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | return $class->$orig(@args); | |||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | has _impl => ( | ||||||||||||||||||||||||||||||||||||||||||
| 23 | init_arg => 'res', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | handles => 'UserAgent::Any::Response::Impl', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | coerce => sub ($res) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | croak 'Passed Response object must be a blessed reference' unless blessed($res); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | if ($res isa HTTP::Response) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | require UserAgent::Any::Response::Impl::HttpResponse; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | return UserAgent::Any::Response::Impl::HttpResponse->new(res => $res); | |||||||||||||||||||||||||||||||||||||||||
| 32 | } elsif ($res isa Mojo::Message::Response) { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | require UserAgent::Any::Response::Impl::MojoMessageResponse; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | return UserAgent::Any::Response::Impl::MojoMessageResponse->new(res => $res); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } elsif ($res isa HTTP::Promise::Response) { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | require UserAgent::Any::Response::Impl::HttpPromiseResponse; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | return UserAgent::Any::Response::Impl::HttpPromiseResponse->new(res => $res); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } elsif ($res->DOES('UserAgent::Any::Response')) { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 40 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | croak 'Unknown Response type "'.ref($res).'"'; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 11 | ); | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||||||||||||||||