Client/Request.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 14 / 14 Conditioncond 80.0% 12 / 15 MC/DCmcdc 70.0% 7 / 10 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 90.2% 65 / 72 CC 13 SCAR 20.1
CC
13
Cov
95%
_build_query_string
11.1
request_params
3.0
BEGIN
1.0
CRAP 7.5
« Client.pm ↑ Summary Utils/URI.pm »
1 # ABSTRACT: request class
2 package PONAPI::Client::Request;
3  
4 7 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use JSON::XS qw< encode_json >;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use PONAPI::Utils::URI qw< to_uri >;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 requires 'method';
11 7 requires 'path';
12  
13 sub request_params {
14 7 ▶ my $self = shift;
Subroutine request_params: called CC=3 SCAR=11.0
Pod undocumented
15  
16 7 my $method = $self->method;
17  
18 return (
19 7 ▶ method => $method,
Branch: 2 branches
BranchTrueFalseTotal
$method eq 'GET' ? : 4 3 7
$self->can('data') ? : 2 1 3
20 path => $self->path,
21 ( $method eq 'GET'
22 ? ( query_string => $self->_build_query_string )
23 : ( $self->can('data')
24 ? ( body => encode_json( { data => $self->data } ) )
25 : ()
26 )
27 )
28 );
29 }
30  
31 sub _build_query_string {
32 4 ▶ my $self = shift;
Subroutine _build_query_string: called CC=11 SCAR=24.1
33  
34 4 my %u;
35  
36 4 ▶ $u{filter} = $self->filter
Branch: 1 branch
BranchTrueFalseTotal
if $self->does("PONAPI::Client::Request::Role::HasFilter") and $self->has_filter 3 1 4
Condition66%2/3
$self->does("PONAPI::Client::Request::Role::HasFilter") and $self->has_filter
!ll&&!rl&&r
013
MC/DC50%1/2
$self->does("PONAPI::Client::Request::Role::HasFilter") and $self->has_filter
$self->does("PONAPI::Client::Request::Role::HasFilter") $self->has_filter
Truth table66%2/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasFilter")B= $self->has_filter
ABresult
0X0
100
111
37 if $self->does('PONAPI::Client::Request::Role::HasFilter') and $self->has_filter;
38  
39 4 ▶ $u{fields} = $self->fields
Branch: 1 branch
BranchTrueFalseTotal
if $self->does("PONAPI::Client::Request::Role::HasFields") and $self->has_fields 2 2 4
Condition100%3/3
$self->does("PONAPI::Client::Request::Role::HasFields") and $self->has_fields
!ll&&!rl&&r
112
MC/DC100%2/2
$self->does("PONAPI::Client::Request::Role::HasFields") and $self->has_fields
$self->does("PONAPI::Client::Request::Role::HasFields") $self->has_fields
Truth table100%3/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasFields")B= $self->has_fields
ABresult
0X0
100
111
40 if $self->does('PONAPI::Client::Request::Role::HasFields') and $self->has_fields;
41  
42 4 ▶ $u{page} = $self->page
Branch: 1 branch
BranchTrueFalseTotal
if $self->does("PONAPI::Client::Request::Role::HasPage") and $self->has_page 2 2 4
Condition66%2/3
$self->does("PONAPI::Client::Request::Role::HasPage") and $self->has_page
!ll&&!rl&&r
022
MC/DC50%1/2
$self->does("PONAPI::Client::Request::Role::HasPage") and $self->has_page
$self->does("PONAPI::Client::Request::Role::HasPage") $self->has_page
Truth table66%2/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasPage")B= $self->has_page
ABresult
0X0
100
111
43 if $self->does('PONAPI::Client::Request::Role::HasPage') and $self->has_page;
44  
45 4 ▶ $u{include} = $self->include
Branch: 1 branch
BranchTrueFalseTotal
if $self->does("PONAPI::Client::Request::Role::HasInclude") and $self->has_include 2 2 4
Condition100%3/3
$self->does("PONAPI::Client::Request::Role::HasInclude") and $self->has_include
!ll&&!rl&&r
112
MC/DC100%2/2
$self->does("PONAPI::Client::Request::Role::HasInclude") and $self->has_include
$self->does("PONAPI::Client::Request::Role::HasInclude") $self->has_include
Truth table100%3/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasInclude")B= $self->has_include
ABresult
0X0
100
111
46 if $self->does('PONAPI::Client::Request::Role::HasInclude') and $self->has_include;
47  
48 4 ▶ $u{sort} = $self->sort
Branch: 1 branch
BranchTrueFalseTotal
if $self->does("PONAPI::Client::Request::Role::HasSort") and $self->has_sort 1 3 4
Condition66%2/3
$self->does("PONAPI::Client::Request::Role::HasSort") and $self->has_sort
!ll&&!rl&&r
301
MC/DC50%1/2
$self->does("PONAPI::Client::Request::Role::HasSort") and $self->has_sort
$self->does("PONAPI::Client::Request::Role::HasSort") $self->has_sort
Truth table66%2/3
A and B
A= $self->does("PONAPI::Client::Request::Role::HasSort")B= $self->has_sort
ABresult
0X0
100
111
49 if $self->does('PONAPI::Client::Request::Role::HasSort') and $self->has_sort;
50  
51 4 return to_uri( \%u );
52 }
53  
54 7 ▶no Moose::Role; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
55  
56 __END__
57  
58 =pod
59  
60 =encoding UTF-8
61  
62 =head1 NAME
63  
64 PONAPI::Client::Request - request class
65  
66 =head1 VERSION
67  
68 version 0.002003
69  
70 =head1 AUTHORS
71  
72 =over 4
73  
74 =item *
75  
76 Mickey Nasriachi <mickey@cpan.org>
77  
78 =item *
79  
80 Stevan Little <stevan@cpan.org>
81  
82 =item *
83  
84 Brian Fraser <hugmeir@cpan.org>
85  
86 =back
87  
88 =head1 COPYRIGHT AND LICENSE
89  
90 This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser.
91  
92 This is free software; you can redistribute it and/or modify it under
93 the same terms as the Perl 5 programming language system itself.
94  
95 =cut
« Client.pm ↑ Summary Utils/URI.pm »