blib/lib/WWW/ORCID/Transport/LWP.pm

filter: Statementstmt 76.0% 19 / 25 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod n/a totaltotal 75.0% 24 / 32 SCAR 7.2
CC
2
Cov
76%
_get_headers
6.0
_build_client
2.0
BEGIN
1.0
CRAP 2.1
« blib/lib/WWW/ORCID/Transport.pm ↑ Summary blib/lib/WWW/ORCID/API/v2_0.pm »
1 package WWW::ORCID::Transport::LWP;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = 0.0401;
7  
8 1 ▶use LWP::UserAgent ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 with 'WWW::ORCID::Transport';
13  
14 1 has _client =>
15 (is => 'ro', init_arg => 0, lazy => 1, builder => '_build_client',);
16  
17 sub _build_client {
18 0 ▶ LWP::UserAgent->new;
Subroutine _build_client: not called CC=1 SCAR=6.9
19 }
20  
21 sub get {
22 my ($self, $url, $params, $headers) = @_;
23 $url = $self->_param_url($url, $params) if $params;
24 my $res = $self->_client->get($url, %$headers);
25 [$res->code, $self->_get_headers($res), $res->content];
26 }
27  
28 sub post_form {
29 my ($self, $url, $form, $headers) = @_;
30 my $res = $self->_client->post($url, $form, %$headers);
31 [$res->code, $self->_get_headers($res), $res->content];
32 }
33  
34 sub post {
35 my ($self, $url, $body, $headers) = @_;
36 my $res = $self->_client->post($url, %$headers, Content => $body);
37 [$res->code, $self->_get_headers($res), $res->content];
38 }
39  
40 sub put {
41 my ($self, $url, $body, $headers) = @_;
42 my $res = $self->_client->put($url, %$headers, Content => $body);
43 [$res->code, $self->_get_headers($res), $res->content];
44 }
45  
46 sub delete {
47 my ($self, $url, $params, $headers) = @_;
48 $url = $self->_param_url($url, $params) if $params;
49 my $res = $self->_client->delete($url, %$headers);
50 [$res->code, $self->_get_headers($res), $res->content];
51 }
52  
53 sub _get_headers {
54 0 ▶ my ($self, $msg) = @_;
Subroutine _get_headers: not called CC=2 SCAR=17.9
55 0 my $headers = {};
56 0 for my $key ($msg->header_field_names) {
57 0 $headers->{lc $key} = $msg->header($key);
58 }
59 0 $headers;
60 }
61  
62 1 1;
« blib/lib/WWW/ORCID/Transport.pm ↑ Summary blib/lib/WWW/ORCID/API/v2_0.pm »