blib/lib/WebService/Bugzilla/Object.pm

filter: Statementstmt 44.7% 17 / 38 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 40.0% 4 / 10 Podpod n/a totaltotal 28.0% 21 / 75 CC 10 SCAR 29.2
CC
10
Cov
29%
_unwrap
42.0
_fetch_full
20.0
_build_id
6.0
CRAP 18.6
↑ Summary lib/WebService/Bugzilla.pm »
1 #!/usr/bin/false
2 # ABSTRACT: Base class for Bugzilla API objects
3 # PODNAME: WebService::Bugzilla::Object
4  
5 # See https://bmo.readthedocs.io/en/latest/api/core/v1/index.html
6  
7 package WebService::Bugzilla::Object 0.001;
8 15 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 15 has client => (
14 is => 'ro',
15 required => 1,
16 weak_ref => 1,
17 );
18  
19 15 has id => (
20 is => 'ro',
21 lazy => 1,
22 builder => '_build_id',
23 predicate => 1,
24 );
25  
26 15 has _api_data => (
27 is => 'ro',
28 init_arg => '_data',
29 writer => '_set_api_data',
30 );
31  
32 15 has _is_loaded => (
33 is => 'rw',
34 default => 0,
35 );
36  
37 0 ▶sub _build_id {
Subroutine _build_id: not called CC=2 SCAR=17.9
38 0 my ($self) = @_;
39 0 ▶ croak 'id not available - object not loaded'
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_api_data 0 0 0
40 unless $self->_api_data;
41 0 return $self->_api_data->{id};
42 }
43  
44 0 ▶sub _fetch_full {
Subroutine _fetch_full: not called CC=4 SCAR=30.0
45 0 my ($self, $uri) = @_;
46 0 ▶ return if $self->_is_loaded;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_loaded 0 0 0
47 0 ▶ return if $self->_api_data && %{$self->_api_data};
Branch: 1 branch
BranchTrueFalseTotal
if $self->_api_data and %{$self->_api_data;} 0 0 0
Condition0%0/3
$self->_api_data and %{$self->_api_data;}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_api_data and %{$self->_api_data;}
$self->_api_data %{$self->_api_data;}
Truth table0%0/3
A and B
A= $self->_api_dataB= %{$self->_api_data;}
ABresult
0X0
100
111
48 0 $self->_is_loaded(1);
49 0 my $res = $self->client->get($uri);
50 0 $self->_set_api_data($self->_unwrap($res));
51 }
52  
53 0 ▶sub _mkuri {
Subroutine _mkuri: not called CC=1 SCAR=6.9
54 0 my ($self, @paths) = @_;
55 0 return join('/', @paths);
56 }
57  
58 0 ▶sub _simple_get {
Subroutine _simple_get: not called CC=1 SCAR=6.9
59 0 my ($self, $path) = @_;
60 0 return $self->client->get($self->_mkuri($path));
61 }
62  
63 0 ▶sub _unwrap {
Subroutine _unwrap: not called CC=6 SCAR=37.4
64 0 my ($self, $res) = @_;
65 0 ▶ return $res unless ref $res eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $res eq "HASH" 0 0 0
66 0 my $key = $self->_unwrap_key;
67 0 ▶ if ($key && exists $res->{$key} && ref $res->{$key} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key and exists $res->{$key} and ref $res->{$key} eq "ARRAY") 0 0 0
Condition0%0/6
$key and exists $res->{$key} and ref $res->{$key} eq "ARRAY"
!ll&&!rl&&r
000
$key and exists $res->{$key}
!ll&&!rl&&r
000
MC/DC0%0/3
$key and exists $res->{$key} and ref $res->{$key} eq "ARRAY"
$key exists $res->{$key} ref $res->{$key} eq "ARRAY"
Truth table0%0/4
A and B and C
A= $keyB= exists $res->{$key}C= ref $res->{$key} eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
68 0 ▶ return $res->{$key}[0] // {};
Condition0%0/2
$res->{$key}[0] // {}
l!l
00
MC/DC0%0/1
$res->{$key}[0] // {}
$res->{$key}[0]
Truth table0%0/2
A
A= $res->{$key}[0]
Aresult
11
00
69 }
70 0 return $res;
71 }
72  
73 0 ▶sub _unwrap_key { undef }
Subroutine _unwrap_key: not called CC=1 SCAR=6.9
74  
75 15 1;
76  
77 __END__
↑ Summary lib/WebService/Bugzilla.pm »