lib/WWW/Hetzner/Storage/API/StorageBoxTypes.pm

filter: Statementstmt 97.3% 37 / 38 Branchbran 66.6% 4 / 6 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 88.8% 56 / 63 CC 7 SCAR 7.7
CC
7
Cov
90%
get_by_name
4.1
_list_page
2.0
_wrap_list
2.0
CRAP 2.2
« lib/WWW/Hetzner/Storage/API/Snapshots.pm ↑ Summary lib/WWW/Hetzner/Cloud/API/Locations.pm »
1 package WWW::Hetzner::Storage::API::StorageBoxTypes;
2 # ABSTRACT: Hetzner Storage Box Types API
3  
4 11 our $VERSION = '0.102';
5  
6 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use WWW::Hetzner::Storage::StorageBoxType;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 11 has client => (
13 is => 'ro',
14 required => 1,
15 weak_ref => 1,
16 );
17  
18 11 with 'WWW::Hetzner::Role::Pagination';
19  
20 6 ▶sub _wrap {
Subroutine _wrap: called CC=1 SCAR=0.0
21 6 my ($self, $data) = @_;
22 6 return WWW::Hetzner::Storage::StorageBoxType->new(
23 client => $self->client,
24 %$data,
25 );
26 }
27  
28 5 ▶sub _wrap_list {
Subroutine _wrap_list: called CC=2 SCAR=7.0
29 5 my ($self, $list) = @_;
30 5 ▶ return [ map { $self->_wrap($_) } @{ $list // [] } ];
Condition50%1/2
$list // []
l!l
50
MC/DC0%0/1
$list // []
$list
Truth table50%1/2
A
A= $list
Aresult
11
00
31 }
32  
33 5 ▶sub _list_page {
Subroutine _list_page: called CC=2 SCAR=7.1
34 5 my ($self, %params) = @_;
35  
36 5 my $result = $self->client->get('/storage_box_types', params => \%params);
37 5 ▶ return ($self->_wrap_list($result->{storage_box_types} // []), $result->{meta});
Condition50%1/2
$result->{"storage_box_types"} // []
l!l
50
MC/DC0%0/1
$result->{"storage_box_types"} // []
$result->{"storage_box_types"}
Truth table50%1/2
A
A= $result->{"storage_box_types"}
Aresult
11
00
38 }
39  
40  
41 1 ▶sub list {
Subroutine list: called CC=1 SCAR=0.0
Pod documented
42 1 my ($self, %params) = @_;
43  
44 1 my ($entities) = $self->_list_page(%params);
45 1 return $entities;
46 }
47  
48  
49 1 ▶sub get {
Subroutine get: called CC=2 SCAR=7.0
Pod documented
50 1 my ($self, $id) = @_;
51 1 ▶ croak 'Storage Box Type ID required' unless $id;
Branch: 1 branch
BranchTrueFalseTotal
unless $id 0 1 1
52  
53 1 my $result = $self->client->get("/storage_box_types/$id");
54 1 return $self->_wrap($result->{storage_box_type});
55 }
56  
57  
58 1 ▶sub get_by_name {
Subroutine get_by_name: called CC=4 SCAR=14.2
Pod documented
59 1 my ($self, $name) = @_;
60 1 ▶ croak 'Name required' unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 1 1
61  
62 1 my $types = $self->list_all(name => $name);
63 1 for my $type (@$types) {
64 2 ▶ return $type if $type->name eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $type->name eq $name 1 1 2
65 }
66 0 return;
67 }
68  
69  
70 11 1;
71  
72 __END__
« lib/WWW/Hetzner/Storage/API/Snapshots.pm ↑ Summary lib/WWW/Hetzner/Cloud/API/Locations.pm »