Pixela/Pixel.pm

filter: Statementstmt 100% 67 / 67 Branchbran 100% 12 / 12 Conditioncond 100% 14 / 14 MC/DCmcdc 100% 7 / 7 Subroutinesub 100% 14 / 14 Podpod 75.0% 6 / 8 totaltotal 98.3% 120 / 122 CC 14 SCAR 9.1
CC
14
Cov
100%
post
4.0
update
4.0
_check_id
3.0
CRAP 2.5
« Pixela.pm ↑ Summary Pixela/User.pm »
1 package WebService::Pixela::Pixel;
2 6 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 our $VERSION = "0.021";
8  
9 44 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10 44 my ($class,$pixela_client) = @_;
11 44 return bless +{
12 client => $pixela_client,
13 }, $class;
14 }
15  
16  
17 49 ▶sub client {
Subroutine client: called CC=1 SCAR=0.0
Pod undocumented
18 49 my $self = shift;
19 49 return $self->{client};
20 }
21  
22 4 ▶sub post {
Subroutine post: called CC=4 SCAR=13.9
Pod documented
23 4 my ($self,%args) = @_;
24 4 my $params = {};
25  
26 #check graphID
27 4 my $id = $self->_check_id($args{id});
28  
29 #check date
30 4 ▶ $params->{date} = $args{date} // croak 'require date';
Condition100%2/2
$args{"date"} // croak("require date")
l!l
31
MC/DC100%1/1
$args{"date"} // croak("require date")
$args{"date"}
Truth table100%2/2
A
A= $args{"date"}
Aresult
11
00
31 3 $params->{date} .= '';
32  
33 #check quantity
34 3 ▶ $params->{quantity} = $args{quantity} // croak 'require quantity';
Condition100%2/2
$args{"quantity"} // croak("require quantity")
l!l
21
MC/DC100%1/1
$args{"quantity"} // croak("require quantity")
$args{"quantity"}
Truth table100%2/2
A
A= $args{"quantity"}
Aresult
11
00
35 2 $params->{quantity}.= '';
36  
37 #check optionalData
38 2 ▶ $params->{optionalData} = $args{optional_data} if $args{optional_data};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"optional_data"} 1 1 2
39  
40 2 my $path = $self->_create_path($id);
41 2 return $self->client->request_with_xuser_in_header('POST',$path,$params);
42 }
43  
44 2 ▶sub get {
Subroutine get: called CC=2 SCAR=6.9
Pod documented
45 2 my ($self, %args) = @_;
46  
47 2 my $id = $self->_check_id($args{id});
48  
49 2 ▶ my $date = $args{date} // croak 'require date';
Condition100%2/2
$args{"date"} // croak("require date")
l!l
11
MC/DC100%1/1
$args{"date"} // croak("require date")
$args{"date"}
Truth table100%2/2
A
A= $args{"date"}
Aresult
11
00
50  
51 1 my $path = $self->_create_path($id,$date);
52 1 return $self->client->request_with_xuser_in_header('GET',$path);
53 }
54  
55 4 ▶sub update {
Subroutine update: called CC=4 SCAR=13.9
Pod documented
56 4 my ($self,%args) = @_;
57  
58 4 my $id = $self->_check_id($args{id});
59  
60 #check date
61 4 ▶ my $date = $args{date} // croak 'require date';
Condition100%2/2
$args{"date"} // croak("require date")
l!l
31
MC/DC100%1/1
$args{"date"} // croak("require date")
$args{"date"}
Truth table100%2/2
A
A= $args{"date"}
Aresult
11
00
62  
63 3 my $params = {};
64  
65 #check quantity
66 3 ▶ $params->{quantity} = $args{quantity} . '' if $args{quantity};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"quantity"} 2 1 3
67  
68 #check optionalData
69 3 ▶ $params->{optionalData} = $args{optional_data} if $args{optional_data};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"optional_data"} 1 2 3
70  
71 3 my $path = $self->_create_path($id,$date);
72 3 return $self->client->request_with_xuser_in_header('PUT',$path,$params);
73 }
74  
75 2 ▶sub increment {
Subroutine increment: called CC=2 SCAR=6.9
Pod documented
76 2 my ($self,%args) = @_;
77 2 my $client = $self->client;
78  
79 2 my $id = $self->_check_id($args{id});
80  
81 2 my $path = $self->_create_path($id);
82 2 $path = $path . '/increment';
83  
84 2 ▶ my $length = $args{length} // 0;
Condition100%2/2
$args{"length"} // 0
l!l
11
MC/DC100%1/1
$args{"length"} // 0
$args{"length"}
Truth table100%2/2
A
A= $args{"length"}
Aresult
11
00
85  
86 2 return $client->request_with_dual_in_header('PUT',$path,$length);
87 }
88  
89 2 ▶sub decrement {
Subroutine decrement: called CC=2 SCAR=6.9
Pod documented
90 2 my ($self,%args) = @_;
91 2 my $client = $self->client;
92  
93 2 my $id = $self->_check_id($args{id});
94  
95 2 my $path = $self->_create_path($id);
96 2 $path = $path . '/decrement';
97  
98 2 ▶ my $length = $args{length} // 0;
Condition100%2/2
$args{"length"} // 0
l!l
11
MC/DC100%1/1
$args{"length"} // 0
$args{"length"}
Truth table100%2/2
A
A= $args{"length"}
Aresult
11
00
99  
100 2 return $client->request_with_dual_in_header('PUT',$path,$length);
101 }
102  
103 2 ▶sub delete {
Subroutine delete: called CC=2 SCAR=6.9
Pod documented
104 2 my ($self,%args) = @_;
105 2 my $client = $self->client;
106  
107 2 my $id = $self->_check_id($args{id});
108 2 ▶ my $date = $args{date} // croak 'require date';
Condition100%2/2
$args{"date"} // croak("require date")
l!l
11
MC/DC100%1/1
$args{"date"} // croak("require date")
$args{"date"}
Truth table100%2/2
A
A= $args{"date"}
Aresult
11
00
109  
110 1 my $path = $self->_create_path($id,$date);
111  
112 1 return $self->client->request_with_xuser_in_header('DELETE',$path);
113 }
114  
115 19 ▶sub _check_id {
Subroutine _check_id: called CC=3 SCAR=11.0
116 19 my ($self,$arg_id) = @_;
117  
118 19 ▶ my $id = $arg_id ? $arg_id : $self->client->graph->id();
Branch: 1 branch
BranchTrueFalseTotal
$arg_id ? : 1 18 19
119 19 ▶ croak 'require graph_id' unless $id;
Branch: 1 branch
BranchTrueFalseTotal
unless $id 1 18 19
120 18 return $id;
121 }
122  
123 17 ▶sub _create_path {
Subroutine _create_path: called CC=2 SCAR=6.9
124 17 my ($self,$id,$date) = @_;
125 17 my $path = 'users/'.$self->client->username.'/graphs/'.$id;
126 17 ▶ return defined $date ? $path . '/' . $date : $path;
Branch: 1 branch
BranchTrueFalseTotal
defined $date ? : 9 8 17
127 }
128  
129  
130 6 1;
131 __END__
« Pixela.pm ↑ Summary Pixela/User.pm »